lqbweb
lqbweb

Reputation: 1708

Shared scope directives with a ngModel in the template

Having something like:

module.directive('myCustomInput', function($compile) {
        return {
            restrict: 'E',
            template: '<input ng-model="$scope.myVar"></input>'
        }
}

This does not bind to the model, the only way I can make it to work is by specifying a variable in the scope: {}, and then use it, which is what actually I don't want.

Is there any solution?

Upvotes: 0

Views: 48

Answers (1)

Anik Islam Abhi
Anik Islam Abhi

Reputation: 25352

You don't need to mention $scope in view

Try like this

<input ng-model="myVar"></input>

Upvotes: 1

Related Questions