angularjs directive - ng-change not working with dropdown list -


in code ng-change not working gives error. why? need execute method show() every time selected value changes. below div tag should visible after selection of valid list value.

 <div class="form-group">   <label>source</label>   <select class="form-control" name="ddlfirst" ngmodel="ddlsource" ng-change="show()">   <option value="null" ng-selected="true">--select sprint--</option>   <option  ng-repeat="s in alls" value="{{s.id}}">{{s.name}}</option>   </select>   </div>    //this div should visible when valid list value selected.s.id hv +ve value on valid list value selection    <div ng-show="ddlsource==isnumber()">   <label> hiiiiii</label>  </div>      result is:    error: [$compile:ctreq] controller 'ngmodel', required directive 'ngchange', can't found!  http://errors.angularjs.org/1.3.15/$compile/ctreq?p0=ngmodel&p1=ngchange      @ regex_string_regexp (angular.js:64)      @ getcontrollers (angular.js:7584)      @ nodelinkfn (angular.js:7773)      @ compositelinkfn (angular.js:7118)      @ compositelinkfn (angular.js:7121)      @ nodelinkfn (angular.js:7764)      @ compositelinkfn (angular.js:7118)      @ compositelinkfn (angular.js:7121)      @ compositelinkfn (angular.js:7121)      @ compositelinkfn (angular.js:7121)

ng-change require ng-model directive . in code
<select class="form-control" name="ddlfirst" ngmodel="ddlsource" ng-change="show()">

it should rather ng-model instead of ngmodel .

here plunker link.

i have created sample code detect change in dropdown.

<div ng-controller='calcctrl'> <label>source</label>  <select class="form-control" name="ddlfirst" ng-model="ddlsource" ng-change="show()">   <option  ng-repeat="s in alls" value="{{s.id}}">{{s.name}}</option>  </select>  </div> 

my jsfile looks this.

 var myapp = angular.module('myapp', []);  myapp.controller('calcctrl', function ($scope) {     $scope.alls=[{name:"ram",id:'1'},{name:"shyam",id:'2'}];     $scope.show = function(){alert("changed");} }); 

i hope solve problem.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -