AngularJS Basics

Directory Structure and Code

To organize angular javascript codes, create directory to manage javascripts.

  • app.js
  • controllers.js
  • service.js

The order to read these file

<script type="text/javascript" src="/javascripts/app/app.js"></script>
<!-- Service Factory -->
<script type="text/javascript" src="/javascripts/app/service.js"></script>
<script type="text/javascript" src="/javascripts/app/controller.js"></script>


Module definition, and dependencies.

var appModule = angular.module("appModule",[]); // Create module


Register services to use this project

    'use strict';
        return new app.List($rootScope);
    // module.service('List',['$rootScope',app.List]);

Register app.List from service implementation as ‘List’


Controller element and event and others

 'use strict';  // Strict mode

  // Page total controller(event etc...)
  module.controller('pageController', function($scope){

  // This is partial controller
  module.controller('partController', function($scope){
     // $scope.$parent.