Tutorial by Examples

A controller is a basic structure used in Angular to preserve scope and handle certain actions within a page. Each controller is coupled with an HTML view. Below is a basic boilerplate for an Angular app: <!DOCTYPE html> <html lang="en" ng-app='MyFirstApp'> <head...
angular .module('app') .controller('SampleController', SampleController) SampleController.$inject = ['$log', '$scope']; function SampleController($log, $scope){ $log.debug('*****SampleController******'); /* Your code below */ } Note: The .$inject will make sure your...
There are a couple different ways to protect your controller creation from minification. The first is called inline array annotation. It looks like the following: var app = angular.module('app'); app.controller('sampleController', ['$scope', '$http', function(a, b){ //logic here }]); The...
In Angular $scope is the glue between the Controller and the View that helps with all of our data binding needs. Controller As is another way of binding controller and view and is mostly recommended to use. Basically these are the two controller constructs in Angular (i.e $scope and Controller As). ...
To create minification-safe angular controllers, you will change the controller function parameters. The second argument in the module.controller function should be passed an array, where the last parameter is the controller function, and every parameter before that is the name of each injected val...
Nesting controllers chains the $scope as well. Changing a $scope variable in the nested controller changes the same $scope variable in the parent controller. .controller('parentController', function ($scope) { $scope.parentVariable = "I'm the parent"; }); .controller('childContro...

Page 1 of 1