Angular JS: ng-include by function
Angular JS: ng-include by function
我在使用 ng-include 时遇到了奇怪的经历。我正在尝试通过触发控制器中定义的函数来获取模板路径,该函数根据传递的参数返回路径。这是我的代码-
<tr ng-repeat="detail in Ctrl.details" ng-include="Ctrl.getTemplate(object)"></tr>
康托勒-
self.getTemplate = function (obj) {
if (<condition>) {
return 'view1';
} else return 'view2';
};
这工作得很好,但我在调试代码时观察到了非常奇怪的行为。在我的表格行中,我有 3 个按钮,我在它们上应用了引导工具提示。每当我悬停它们时,工具提示就会出现,鼠标左边 getTemplate(( 就会被调用。有人知道为什么会这样吗?
这是
预期行为。
看看这篇文章。Angular 需要检查 ng-include
的表达式是否已更改。为此,它需要评估每个摘要循环Ctrl.getTemplate(object)
,因为没有其他方法可以找出其返回值是否已更改,因此需要将新值传递给ng-include
。
相关文章:
- 直接在函数声明上使用function.prototype.bind
- jQuery:.click(function(){(element),collapse('show',f
- 如果连接类型为none,则Javascript Function Only警报
- onLoad function phonegap android
- reducers在redux中得到Function not Object,what'it’他错了
- WIll window.addEventListener(“加载”,function(),false);等待浏览器自动填
- $(document).ready和jQuery(function($)不工作;jQuery已定义,但脚本尚未定义;t进
- Javascript onunload function
- 在init function()中调用getElementById(“..”),而不是想用它做点什么的函数
- spyOn:应为间谍,但得到了Function
- getDocument by id/get input text from button dons'不起作用
- (typeof variable === “function”) 和 jQuery.isFunction() 有什么区别
- this内部的值返回this.each(function(){})
- 如何在JavaScript中创建类似于something.function()的函数
- 如何通过 Function.prototype.apply() 更改调用函数的参数
- Div and ul list side by side
- 控制台中的“function floor(){[本机代码]}”是什么
- ASPX Jquery 1.11 $(Document).ready(function() {} was skipped
- Function.prototype.call和Function.protoype.all只应用一个参数
- Angular JS: ng-include by function