Example:This example uses ng-controller Directive to display the concatenation of First and Second input of a user.
This first example demonstrated a controller object with two properties:Fname and Lname.In AngularJS, the function($scope) is defined when controller is defining and it’s return the concatenation of the $scope.firstname and $scope.lastname. Here a controller can also have methods (variables as functions):
Before writing the name:
After writing the name:
Controllers in External files
In larger application it is common to store controllers in a external file, you just need to copy that file nime and paste it in a <script> tag. Here the external file name is “geeksforgeeks.js”
- How to use filter within controllers in AngularJS ?
- How to share data between controllers in AngularJS ?
- AngularJS | ng-show Directive
- Difference between Bootstrap and AngularJS
- AngularJS | currency Filter
- How to convert string into a number using AngularJS ?
- Introduction to AngularJS
- AngularJS | Factory Method
- AngularJS | ng-init Directive
- AngularJS | ng-if Directive
- AngularJS | ng-dblclick Directive
- AngularJS | ng-keypress Directive
- AngularJS | ng-keydown Directive
- AngularJS | ng-keyup Directive
- AngularJS | ng-href Directive
- AngularJS | ng-focus Directive
- AngularJS | ng-hide Directive
- AngularJS | ng-disabled Directive
- AngularJs | ng-list Directive
- AngularJS | ng-mouseup Directive
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.