angularjs - Angular Scope variables are not updated in Controller when changed in UI and vice versa -


i have below controller

angular.module("test")         .controller("anyctrl", ["$scope", "$state","$timeout",  anyctrl]);      function anyctrl($scope,$state,$timeout) {         $scope.jumpoutnotes="test";      } 

and below view

<!-- start of  jump out reason window  --> <div class="col-md-8">     <div class="panel panel-primary">          <div class="panel-body">             <div class="form-group row">                 <label class="col-md-3 control-label" for="jumpoutnotes">notes</label>                  <div class="col-md-6">                     <textarea class="form-control"                               id="jumpoutnotes"                               name="jumpoutnotes"                               type="text"                               rows="4"                               cols="200"                               placeholder="notes"                               ng-model="jumpoutnotes"></textarea>                 </div>             </div>             <div class="form-group row">                 <div class="col-md-2">                     <button ng-click="savejump(jumpoutnotes);" class="btn btn-primary btn-sm">save jump out</button>                 </div>             </div>         </div>      </div> </div> 

when call savejump function, re-initate value of ng-model variable not reflected in ui , try access value in function shows me last value

$scope.savejump= function(jumpoutnotes){                                       alert($scope.jumpoutnotes+ " : "+jumpoutnotes);              $scope.jumpoutnotes="";          } 

the value passed in function argument latest value in view scope value in alert remain "test". not sure causing issue. using ui-router views.

below code stateprovider

angular.module("test").config(["$stateprovider", "$urlrouterprovider", "$locationprovider", "$provide",             function ($stateprovider, $urlrouterprovider, $locationprovider, $provide) {                  $stateprovider                      .state("servicemain", {                         url: "/main",                         templateurl: "../resources/app/service.html",                         controller: "anyctrl"                         })                     }); 


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -