scope test

by cm0s

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js"></script>
<div ng-app="app">
<div ng-controller="AppCtrl">
    
    <categories categories-model="cat"></categories>
    <categories categories-model="cat2"></categories>
</div>
</div>

JavaScript

angular.module('app', [])
    .controller('AppCtrl', function($scope, $http){
       // $scope.categoriesTree = [{title:'catA'},{title:'catB'}];
        $scope.cat2 = '222';

    })
    .directive('categories', function () {
        return  {
            restrict: 'E',
            scope: {
                categoriesModel: "="
            },
            template: '<input type="text">',
            link: function (scope, element, attrs)
            {
                  scope.$watch('categoriesModel', function(newValue, oldValue){
                      var test;
                  },true)
            }
        }
    });