I have a directive that will use ng-model to set its value.
The question is that this directive has internal components that will also be useless for the scope, so I need to isolate its scope, but still maintain the ng-model binding to the outside world.
How can i achieve this?
This is the directive:
angular.module('app', []).directive('myDirective', function() { return { restrict: 'E', require: 'ngModel', link: function(scope, element, attr, ngModel) {
<my-directive ng-model="prop"></my-directive>
As you can see, the directive should set prop as its value, but it should not expose userInput in the parent scope defined in <input ng-model="userInput"/> .
How can I only make prop available in the parent area?
source share