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 | API
- AngularJS | ng-jq Directive
- AngularJS | Filters
- AngularJS | Directive
- AngularJS | Routing
- AngularJS | Tables
- AngularJS | ng-app Directive
- AngularJS | Includes
- AngularJS | Services
- AngularJS | ng-value Directive
- AngularJS | HTML DOM
- AngularJS | Forms
- AngularJS | Modules
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.