一、创建项目目录

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模块

 

相关文章:

  • 2021-06-18
  • 2022-02-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-02
  • 2021-07-28
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
相关资源
相似解决方案