Knowledge Management Banner

Knowledge Management Banner

Controller vs $Scope , Routes case sensitive , $route service

Controller vs $Scope

  • Controller as syntax makes your code more readable when working with nested scope
  • If you wish to use $scope than it is necessary to inject it into controller where controller as syntax, there is no need for injection
Routes and Case Sensitive

  • In AngularJS  by default the routes are case sensitive, to make the routes case insensitive, set CaseInsensitiveMatch property to true.
 ngApp.config(function ($routeProvider, $locationProvider) {   
   $routeProvider   
    .when("/", {   
     templateUrl: "Templates/Home.html",   
     controller: "HomeCntrl",  
     caseInsensitiveMatch: true   
    })   
 });  

AngularJS reload service

In angular Application on clicking href it does not reloads page, hence to reload it is necessary to click on browsers reload button, which will reload entire application. To avoid reloading entire application and place only one request it is necessary to use $route service. It has to be injected into controller.

 $scope.ClickMe = function () {  
   $route.reload();  
 }  






No comments

Powered by Blogger.