angularjs - angular js - scope variable dont change on 2 way data binding -


i new angular js.

my controller : var myapp= angular.module('myapp', ['ngroute']);

// configure our routes myapp.config(function($routeprovider) {     $routeprovider          // route home page         .when('/', {             templateurl : 'pages/person.html',             controller  : 'personcontroller'         })          // route contact page         .when('/add', {             templateurl : 'pages/addgroup.html',             controller  : 'groupcontroller'         }); }); myapp.controller('groupcontroller', function($scope) {         $scope.user = 'alex';         $scope.print = function()          {             alert($scope.user);         };     }); 

my view :

<div ng-controller="groupcontroller">   name: <input type="text" ng-model="user">     <button ng-click='print()'>print</button>   {{user}} </div> 

when change input value "mila" example reflect in view, when click print button still getting alert "alex" name.

how can make scope.user change ? cant understand missing here 2 way data binding. !

three things,

  • check if have <div ng-view=""></div> in index.html or ever source page is. different views, i.e., views (person.html , addgroup.html) stated under routing injected.
  • remove declaration of ng-controller="groupcontroller" addgroup.html
  • double check if urls have provided under routing correct.
  • which version of angular using? check if version using requires angular-route.js. if please include js.

check if score positives on above mentioned bullets!


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -