Skip to Main Content
AngularJS Web Application Development Blueprints
book

AngularJS Web Application Development Blueprints

by Vinci J Rufus
August 2014
Intermediate to advanced content levelIntermediate to advanced
300 pages
6h 9m
English
Packt Publishing
Content preview from AngularJS Web Application Development Blueprints

Creating our application-level controller

As we build our app, we are going to need a couple of scope objects that would be used across the entire application.

We can define these objects in an AppCtrl controller and map it high up in the DOM tree structure so that they can be easily inherited down to the child scopes. Create the AppCtrl controller function in our controllers.js file and then add the following scope objects:

.controller('AppCtrl', ['$scope', 'categoryService',
        function($scope, categoryService) {
            $scope.categories = categoryService.getCategories();
            $scope.user = {};
            $scope.shoppingBasket = [ ];
        }
]);

As you can see, we are making use of both getCategories and categoryService. So, let's go ahead and create these in our services.js ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

AngularJS: Maintaining Web Applications

AngularJS: Maintaining Web Applications

Rodrigo Branas, Chandermani, Matt Frisbie, Amos Q. Haviv
AngularJS

AngularJS

Shyam Seshadri, Brad Green
Professional AngularJS

Professional AngularJS

Valeri Karpov, Diego Netto
Pro AngularJS

Pro AngularJS

Adam Freeman

Publisher Resources

ISBN: 9781783285617Supplemental Content