Angular JS – Working with Modules


<!DOCTYPE html>
<html xmlns="">
    <title>Angular JS</title>
        I can use modules to avoid using global function for my controllers.
        To do this I define an app object, registered with a particular name,
        then I refer that name as the app name in the "data-ng-app" directive
    <div data-ng-app="myApp" data-ng-controller="myController">
        <p>The full name is {{ firstName + " " + lastName }}</p>
    <script src="//"></script>
    <script src="//"></script>
    <script src="JS/Default05/myApp.js"></script>
    <script src="JS/Default05/myCtrl.js"></script>
        //I moved this code to myApp.js!!!
        ////This is the app object
        //var app = angular.module("myApp", []);
        //I moved this code to myCtrl.js!!!
        ////I'm adding the controller to the app object
        //app.controller("myController", function ($scope) {
        //    $scope.firstName = "John";
        //    $scope.lastName = "Doe";

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s