コントローラは状態で呼び出されます。オブジェクト(変数)を指令angjsに渡す
.controller('test', function($scope) {
$scope.variable = 'Hello';
$scope.other = 'Hi';
})
.directive('customDir', function() {
return {
restrict: 'A',
link: function($scope, element, attrs) {
attrs.customDir += ' Word';
}
}
});
<input type="text" custom-dir="variable" />
<div>{{variable}}</div>
<input type="text" custom-dir="other" />
<div>{{other}}</div>
私は$ scope.variableと$ scope.other "ことば" を受け取るには、ディレクティブで渡された変数の値を変更することができなければならないことが必要です。
外部変数を変更できるように指示しますか? – dfsq
'input'ボックスに入力されたものに基づいて'変数 'だけを変更する指令について質問していますか? – CShark
@ dfsq Yeeah .... – paulorwd