我有动态创建输入标签的指令。我需要在更改事件中获取已创建输入的值。取而代之的是,参数中的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);
}
}
});