javascript - $watch is not being hit in Angular's directive when a checkbox's value is changed -


i have directive setup this.

angular.module('app')   .directive('bootstrapcheck', function () {     return {       restrict: 'a',       require: '?ngmodel',       link: function (scope, element, attrs, ngmodel) {         $.getscript("../../scripts/js/checkboxfunctions.js",  function () {         });         scope.$watch(attrs.ngmodel, function (newvalue, oldvalue) {           //debugger;         });       }     };   }); 

and it's html looks

<section id="dashboard-view" data-ng-controller="dashboard vm">   <input type="checkbox" ng-model="vm.my.bool.prop" ng-checked="vm.my.bool.prop" bootstrap-check> </section> 

and property setup this

var vm = this; vm.my = {   bool: {     prop: true   } }; 

it seems check-box bound property. whenever click check-box expect hit debugger not working.

i think don't have jquery loaded on page $.getscript throwing exception due $watch never executed.

if remove code sure $watch work fine.

demo http://plnkr.co/edit/eb3yoccf1n9tliaawnrm?p=preview


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -