我有下面的例子,我想返回之前执行范围功能的内容,但它不AngularjJS指令范围功能执行
directives.directive('itemElement', function() {
return {
restrict : 'E',
scope : function(scope) {
var itemModelVar = getValue(scope.item.testdata, field.caption);
console.log('test');// this is not executed at all for example
return {
item : '=item',
field : '=field',
schematypes : '=schematypes',
itemmodel : itemModelVar
};
},
templateUrl : 'partials/templates/item-simple.html'
};
});
这导致itemModelVar是不确定的。
我以为计算器是免费的仇敌。你很有弹性,男人! – alknows
你能解释一下你为什么想这样做吗? “范围”通常不被用来做这件事。如果你想添加一个逻辑函数,请查看'controller'。 –