Created
February 19, 2013 19:18
-
-
Save fdietz/4988944 to your computer and use it in GitHub Desktop.
Recipes with Angular.js: Controllers - Encapsulating a Model Value with a Controller Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MyCtrl($scope) { | |
$scope.value = 1; | |
$scope.getIncrementedValue = function() { | |
return $scope.value + 1; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="js/angular.js"></script> | |
<script src="js/app.js"></script> | |
<link rel="stylesheet" href="css/bootstrap.css"> | |
</head> | |
<body ng-app> | |
<div ng-controller="MyCtrl"> | |
<p>{{getIncrementedValue()}}</p> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment