Last active
January 22, 2016 22:25
-
-
Save ElyDotDev/418d39853049a1d1408e to your computer and use it in GitHub Desktop.
دوره آموزش AngularJS - کنترلگرها (Controllers): http://blog.allii.ir/2016/01/angularjs-beginner-intermediate-course-controllers
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- AngularJS 1.4.8 !--> | |
<script src="../src/angular.min.js"></script> | |
<script src="module.js"></script> | |
<script src="addition-controller-params.js"></script> | |
</head> | |
<body ng-app="app"> | |
<p ng-controller="AdditionController"> | |
{{add(number, 2)}} is not the same as {{add(number, "2")}} | |
<br> | |
2 + 2 + 2 + 2 = {{add(2, add(2, add(2, 2)))}} | |
</p> | |
</body> | |
</html> |
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 AdditionController($scope) | |
{ | |
$scope.number = 2; | |
$scope.add = function (operand1, operand2) | |
{ | |
return operand1 + operand2; | |
} | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- AngularJS 1.4.8 !--> | |
<script src="../src/angular.min.js"></script> | |
<script src="module.js"></script> | |
<script src="addition-controller.js"></script> | |
</head> | |
<body ng-app="app"> | |
<p ng-controller="AdditionController"> | |
<select ng-model="operand1" ng-options="x for x in options"></select> | |
+ <select ng-model="operand2" ng-options="x for x in options"></select> | |
= {{add()}} | |
</p> | |
</body> | |
</html> |
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 AdditionController($scope) | |
{ | |
$scope.operand1 = 0; | |
$scope.operand2 = 0; | |
$scope.add = function () | |
{ | |
return $scope.operand1 + $scope.operand2; | |
} | |
$scope.options = [0, 1, 2, 3, 4]; | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- AngularJS 1.4.8 !--> | |
<script src="../src/angular.min.js"></script> | |
<script src="module.js"></script> | |
<script src="count-controller.js"></script> | |
</head> | |
<body ng-app="app"> | |
<p ng-controller="CountController"> | |
There are {{count()}} months in a year. | |
</p> | |
</body> | |
</html> |
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 CountController($scope) | |
{ | |
$scope.count = function () | |
{ | |
return 12; | |
} | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- AngularJS 1.4.8 !--> | |
<script src="../src/angular.min.js"></script> | |
<script src="module.js"></script> | |
<script src="empty-controller.js"></script> | |
</head> | |
<body ng-app="app"> | |
<p ng-controller="EmptyController"> | |
</p> | |
</body> | |
</html> |
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 EmptyController() | |
{ | |
}; |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- AngularJS 1.4.8 !--> | |
<script src="../src/angular.min.js"></script> | |
<script src="module.js"></script> | |
<script src="form-submit-controller.js"></script> | |
</head> | |
<body ng-app="app"> | |
<div id="form_wrapper" ng-controller="FormSubmitController"> | |
<form ng-show="notSubmitted"> | |
<input type="text" name="feedback"/> | |
<input type="submit" value="Submit Feedback" ng-click="toggle()"/> | |
</form> | |
<div ng-hide="notSubmitted">Thanks for submitting your feedback!</div> | |
</div> | |
</body> | |
</html> |
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 FormSubmitController($scope) | |
{ | |
$scope.notSubmitted = true; | |
$scope.toggle = function () | |
{ | |
$scope.notSubmitted = !$scope.notSubmitted | |
}; | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- AngularJS 1.4.8 !--> | |
<script src="../src/angular.min.js"></script> | |
</head> | |
<body ng-app="app"> | |
<!-- Other examples to be inserted here. --> | |
</body> | |
</html> |
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 MessageController() | |
{ | |
this.message = "This is a model."; | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- AngularJS 1.4.8 !--> | |
<script src="../src/angular.min.js"></script> | |
<script src="module.js"></script> | |
<script src="message-controller-scope.js"></script> | |
</head> | |
<body ng-app="app"> | |
<p ng-controller="MessageController"> | |
{{message}} | |
</p> | |
</body> | |
</html> |
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 MessageController($scope) | |
{ | |
$scope.message = "This is a model."; | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- AngularJS 1.4.8 !--> | |
<script src="../src/angular.min.js"></script> | |
<script src="module.js"></script> | |
<script src="message-controller-as.js"></script> | |
</head> | |
<body ng-app="app"> | |
<p ng-controller="MessageController as controller"> | |
{{controller.message}} | |
</p> | |
</body> | |
</html> |
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
angular.module('app', []); | |
angular.module('app').config(['$controllerProvider', function ($controllerProvider) | |
{ | |
$controllerProvider.allowGlobals(); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment