AngularJS: Genericised angular.copy and added JSDoc

This commit is contained in:
John Reilly
2014-08-22 12:09:25 +01:00
parent d4ad1f4f85
commit 1b247dd0c7
2 changed files with 45 additions and 1 deletions
+31
View File
@@ -569,3 +569,34 @@ angular.module('docsTabsExample', [])
templateUrl: 'my-pane.html'
};
});
interface copyExampleUser {
name?: string;
email?: string;
gender?: string;
}
interface copyExampleScope {
user: copyExampleUser;
master: copyExampleUser;
update: (copyExampleUser) => any;
reset: () => any;
}
angular.module('copyExample', [])
.controller('ExampleController', ['$scope', function ($scope: copyExampleScope) {
$scope.master = { };
$scope.update = function (user) {
// Example with 1 argument
$scope.master = angular.copy(user);
};
$scope.reset = function () {
// Example with 2 arguments
angular.copy($scope.master, $scope.user);
};
$scope.reset();
}]);