AngularJS实现单页面应用

一、创建项目目录

二、angularJS模块组织

  2.1 在index.html页面引入angular主文件包和angular路由模块的包

  2.2 创建app.js模块

    在index.html页面引入app.js模块

var YK = angular.module('Yk',['ngRoute','Controllers');

 

  2.3 创建controllers.js模块

    在index.html页面引入controllers.js模块

//实例一个模块,用来专门管理所有的控制器
angular.module('Controllers',[])
.controller('DemoController',['$scope',function($scope){
    //在视图模块必须调用控制器才能启用,在视图模块需加上ng-controller='DemoController'
   console.log('启动了')
}]

  2.4 创建directives.js模块

    在index.html页面引入directives.js模块

  2.5 创建services.js模块

    在index.html页面引入services.js模块

 

posted @ 2017-02-23 18:09  IT小师妹  阅读(1509)  评论(0)    收藏  举报