入力タグを動的に作成するディレクティブがあります。変更イベントで作成された入力の値を取得する必要があります。その代わりに、引数のname
属性は未定義です。ディレクティブコントローラーで値を取得するには?$scope
controller
ng-model
module.directive('createControl', function($compile, $timeout){
return {
transclude: true,
restrict: 'A',
scope: {
name: '=name'
},
link: function(scope, element, attrs){
// simplified version
tag = '<input type="text" ng-model="name"/>'
element.append(html);
controller: function($scope){
// In the controller I need to get value of created input on change event
console.log($scope);
}
}
});