ディレクティブと分離されたスコープで非常に奇妙な現象が発生します。スコープ内の属性は、属性の命名に応じて機能するか機能しません。私が使用する場合
{check:'@check'}
それはうまく動作し、期待どおりです。ただし、使用する場合:
{checkN:'@checkN'}
定義された関数が割り当てられることはありません。例は次のようになります。
HTML:
<item ng-repeat="list_item in model.list" model="list_item" checkN="checkName()" check="checkName()" position="$index"></item>'
Javascript
app.directive('item', function(){
return {
restrict: 'E',
replace : false,
scope:{
$index: '=position',
check: '&check',
checkN: '&checkN',
model:'='
},
template: '',
link: function(scope, element, attrs){
console.log(scope.check())
console.log(scope.checkN())
}
}
});
コンソールには次のように表示されます。
The checkName function has been called [which is the return string of the function]
undefined
大文字の使用法に依存する可能性は本当にありますか?これは非常に「予期しない」動作です。
ご協力いただきありがとうございます
シャッキー