5 Here fullname is a function of scopestudent object and whose task to return

5 here fullname is a function of scopestudent object

This preview shows page 10 - 14 out of 23 pages.

5)Here fullname is a function of $scope.student object and whose task to return the combined name.6)Fullname function we’re getting the student object and then return the combined value.7)As a note, we can also defined controller object in separate JS file.Now we can use StudentController object in ng-model to get the values from controller by using the expression.Enter first name: <input type = "text" ng-model = "student.firstName"><br>Enter last name: <input type = "text" ng-model = "student.lastName"><br><br>You are entering: {{student.fullName()}}Here student.firstname and student.lastname were place to ng-model and in page itwill show default values which is assigned in JS file.And fullname() method can give in two ways a) expression or b) ng-binds.Example for ng-controller (Angular JS Controller):<html><head><title>Angular JS Controller</title><script src = "></script></head><body><h2>AngularJS Sample Application</h2><div ng-app = "mainApp" ng-controller = "studentController">Enter first name: <input type = "text" ng-model = "student.firstName"><br><br>Enter last name: <input type = "text" ng-model = "student.lastName"><br>
Background image
<br>You are entering: {{student.fullName()}}</div><script>var mainApp = angular.module("mainApp", []);mainApp.controller('studentController', function($scope) {$scope.student = {firstName: "Mahesh",lastName: "Parashar",fullName: function() {var studentObject;studentObject = $scope.student;return studentObject.firstName + " " + studentObject.lastName;}};});</script></body></html>Angular JS – Filters:Filter are used to change modify the data and the clubbed into expression or directives using pipe character. Following is the list commonly used in directives.1)Uppercase : It Convert the Text into Uppercase2)Lowercase: it convert the text into lowercase3)Currency: It place currency symbol before numeric value.4)Filter: filter the array to a subset of it based on provided criteria.5)Order BY: orders the array based on provided criteria.Uppercase Filter:
Background image
Background image
<tr><td>Enter fees: </td><td><input type = "text" ng-model = "student.fees"></td></tr><tr><td>Enter subject: </td><td><input type = "text" ng-model = "subjectName"></td></tr></table><br/><table
Background image
Image of page 14

You've reached the end of your free preview.

Want to read all 23 pages?

  • Spring '18
  • Brian LeClaire
  • ng-app

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture