Why value of the ng-model is not updated with the expression. Before 
ng-model is defined value get updated

Value will be updated as soon as phase2 or phase3 changes

*<input type="text" name="phase1" value="{{phase2 - phase3}}" ></input>*


Value will not be updated

*<input type="text" name="phase1" value="{{phase2 - phase3}}" 
ng-model="phase1"></input>*


So I think of writing a directive which will evaluate the expression inside 
the directive and updated the output to model, 

Here is html it will look like

*<input type="text" name="phase1" ng-model="phase1" my-value="{{phase2 - 
phase3}}" my-model-value></input>*



*Directive:*
*myApp.directive('myModelValue', function(){*
*return {*
*            restrict: 'A',*
*            require: 'ngModel',*
*            scope: {*
*                model: '=ngModel',*
*                value: '@myValue'*
*            },*
*            link: function (scope, element, attr, controller) {*

*                scope.model = scope.value;*
*            }*
*        };*

*});*

This directive evaluate only at load time, but I want 
to continuously update/watch as the dependent fields (phase2 & phase3) 
changes. 

I can update value from controller but I want to do it from html. Please 
help me it it possible or against the working of angular

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to