Contents tagged with $watch

  • $watch with controller as in Angularjs

    Hello everybody,

    today I want to write few words about interesting case which I faced.

    Recently my company asked me to follow code convention of John Papa according to which I shouldn't use in my controller code $scope, but instead use vm. 

    In code it looks like this:



        .controller(cnt, mosController);//register

    morningStarController.$inject = ['$scope'];

    and continuation:

    function mosController($scope) {    var vm = this;

        var settings = {};

        vm.settings = jsonSettings;

    Then question arise, how to use $watch or how to track variable?

    Below goes way of implementing it with help of $scope:

    var variable = 5;

    $scope.variable = variable;

    $ … more