Skip to main content

Posts

Showing posts from March 9, 2017

ControllerAs Syntax in AngularJS - Best Practice

Here we will learn why we need ControllerAs in angularjs All we know communication between controller and View happens via $scope. Let have a code below AngularJS: <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) {     $scope.firstname = "Devesh"; }); </script> HTML : <div ng-app="myApp" ng-controller="myCtrl">     Name: <input ng-model="firstname">     <h1>{{firstname}}</h1> </div> Here we have few issues 1. Binding everything to $scope, will increase  watch list of the $digest loop. which will cause performance issue so angularJs include ControllerAs syntax. ControllerAs syntax AngularJS: <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) {     this.firstname = "Devesh"; }); </script> HTML  <div   ng-app="myApp"  ...

Contact Form

Name

Email *

Message *