AngularJS Sample Application - 2

AngularJS - First Application

ng-app − This directive defines and links an AngularJS application to HTML.
ng-model − This directive binds the values of AngularJS application data to HTML input controls.
ng-bind − This directive binds the AngularJS Application data to HTML tags.

var mainApp = angular.module("mainApp", []);

mainApp.controller('studentController', function ($scope) {
    $scope.student = {
        firstName: "John",
        lastName: "Doe",
        fees: 500,
        subjects: [{
            name: 'Physics',
            marks: 70
        }, {
            name: 'Chemistry',
            marks: 80
        }, {
            name: 'Math',
            marks: 65
        }],
        fullName: function () {
            var studentObject;
            studentObject = $scope.student;
            return studentObject.firstName + " " + studentObject.lastName;
        }
    };

});
mainApp.directive('capitalize', function () {
    return {
        require: 'ngModel',
        link: function (scope, element, attrs, modelCtrl) {
            modelCtrl.$parsers.push(function (input) {
                return input ? input.toUpperCase() : "";
            });
            element.css("text-transform", "uppercase");
        }
    };

});
AngularJS Sample Application - 2 AngularJS Sample Application - 2 Reviewed by Bhaumik Patel on 7:27 PM Rating: 5