Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Declaring modules in Angularjs

    • 0
    • 3
    • 2
    • 0
    • 0
    • 0
    • 0
    • 0
    • 255
    Comment on it

    A module is a container for different part of an App which includes controller, services, filters, directives and many more.

    We can also say that it is a collection of controllers, filters, services, directives, etc.

    Syntax for creating a module:

    var demoModule = angular.module('demoModule', []);
    

    In this, angular.module is a global for creating and retrieving the angular modules.

    In this, [] parameter is used to define the dependent modules.

    Syntax for adding the controllers, directives and services in the module:

    For Services:

    demoModule.service('demoService', function(){...});
    

    For Directives:

    demoModule.directive("demoDirective", function(){...});
    

    For Controller:

    demoModule.controller("demoCtrl", function($scope) {...});
    

    Hope this will help you with module.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: