我有此块出现在十个不同的管理页面上:
<div class="displayTable w100p"
id="modalTitle">
<div>
<div>
<span>{{home.modal.title}} {{home.modal.data.number}}</span>
<span ng-show="home.modal.data.name"> - {{ home.modal.data.name | truncate:true:50:' ...' }}</span>
</div>
<div class="alignRight fadein fadeout"
id="modalMessage"
ng-model="home.modal.message"
ng-show="home.modal.message">
{{home.modal.message}}
</div>
</div>
</div>
我听说过指令,也包括指令,但是我想知道是否可以通过这些方式将这些文字包括在页面中?如果是这样,那将是最好的。请注意,以上代码块在我所有的管理页面中均相同。
步骤1。
将您的html保存到单独的文件fe path / modal.html中。
步骤2a。
指示:
app.directive('modal', function(){
return: {
restrict: "AE",
templateUrl: "path/modal.html"
}
})
用它。
<div modal></div>
步骤2b。
包括:
<div ng-include="'path/modal.html'"></div>
PS检查您的home变量是否在调用的作用域上限中定义。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句