Showing posts with label Angular Js. Show all posts
Showing posts with label Angular Js. Show all posts

Difference between angular.copy() and assignment (=).

$cope.context = 'some text';
$scope.master = context;
Thus in the later case, if you we're to change something in $scope.master you would also change context.
But in $scope.master = angular.copy($scope.context);
 angular.copy() performs a deep copy of the argument - essentially creating a new object - whereas using the assignment operator = just assigns reference's.
For more details on angular.copy visit Here.
     

How To Call Function after ng-repeat get Load ?



<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js"></script>
 <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.0.js"></script>
<script>
               var App = angular.module('myApp', ['ui.bootstrap']);
                App.directive("repeatEnd", function(){
                    return {
                        restrict: "A",
                        link: function (scope, element, attrs) {
                            if (scope.$last) {
                                scope.$eval(attrs.repeatEnd);
                            }
                        }
                    };
                });

           App.controller('myctrl',['$scope',function($scope)
            {

                     $scope.names = '["test","Tst2"]';
                      var onEnd = function(){
                             console.log('load is complete');
                      };

            }]);
</script>

<body ng-app="myApp" class="container" ng-controller="myctrl" id="LineSite">
        <div ng-repeat="name in names" repeat-end="onEnd()"/>
</body>