我在非HTML5模式下使用ng-router创建文档。所有链接都应转换为href="#!/path“。默认情况下,标签{@href=}创建路径“path”。
这种行为是可配置的吗?
发布于 2017-07-10 22:58:00
我所发现的是,ngdoc正在使用link过滤器。
您可以通过两个简单的步骤覆盖该过滤器。
创建一个包含以下内容的文件(./filters/link.js):
var _ = require('lodash');
module.exports = function() {
return {
name: 'link',
process: function(url, title, doc) {
return _.template('{@link ${url} ${title} }')({ url: '#!/'+url, title: title });
}
};
};在您必须注册(覆盖)它之后。在您的dgeni配置文件中放入以下内容:
...
.config(function(templateEngine, getInjectables) {
templateEngine.filters = templateEngine.filters.concat(getInjectables([
require('./filters/link')
]));
})
...这将在名称link下注册一个新的过滤器。因为它是在ngdoc配置之后运行的,所以它将覆盖现有的link过滤器。
希望能有所帮助。
https://stackoverflow.com/questions/42781903
复制相似问题