Ng-model Not Working For Attribute Directive
I have a simple controller: .controller('TestController',['$scope', function($scope) { this.p = {}; this.p.name = 'Foo'; this.p.surname = 'Bar'; }]); And I have a dire
Solution 1:
I forked your Plunker to add Transclusion. The Directive Transcludes the element, replacing it entirely. It then takes the cloned (original contents) and inserts them into the Transclusion, making the original elements become compiled as part of the directive.
app.directive('cronosDataset',[function() {
return {
restrict: 'A',
controller:'TestController',
controllerAs: "ctrl",
scope: {
cronosDataset : "@"
},
transclude: 'element',
replace: true,
link: function(scope, elem, attrs, ctrl, transclude) {
transclude(scope, function(clone) {
elem.after(clone);
});
}
};
}])
Post a Comment for "Ng-model Not Working For Attribute Directive"