私のディレクティブにはコントローラーがあり、渡されたディレクティブの値を渡す方法を考えています。下の例では、 'name'はコンソールにポストされていませんが、レンダリング時にhtmlに表示されます。明らかに私の例は単純化されていますが、その点が分かります。角度の指示子コントローラに値を渡す方法は?
angular.module('myApp')
.directive('helpLabel', function() {
return {
restrict: 'E',
scope: {
name: '@',
},
template: '<span>{{name}}</span>',
controller: function ($scope) {
console.log(name);
}
};
});
<helpLabel name="test"></helpLabel>