app/
----- components/
---------- users/
--------------- controllers/
-------------------- users.controller.js
--------------- views/
-------------------- user-list.tpl.html
--------------- app.users.js
--------------- app.users.routes.js
---------- roles/
--------------- controllers/
-------------------- roles.controller.js
--------------- views/
-------------------- role-list.tpl.html
--------------- app.roles.js
--------------- app.roles.routes.js
----- app.js
assets/
----- libs/
---------- angular/
index.html

index.html

<!DOCTYPE html>
<html ng-app="app">
<head>
<title></title>
<meta charset="utf-8" />
</head>
<body>
<ul>
<li>
<a href="#/users">Users</a>
</li>
<li>
<a href="#/roles">Roles</a>
</li>
</ul> <ng-view></ng-view> <script type="text/javascript" src="/assets/libs/angular/angular.min.js"></script>
<script type="text/javascript" src="/assets/libs/angular/angular-route.min.js"></script>
<script type="text/javascript" src="/app/app.js"></script>
<script type="text/javascript" src="/app/components/users/app.users.js"></script>
<script type="text/javascript" src="/app/components/users/app.users.routes.js"></script>
<script type="text/javascript" src="/app/components/users/controllers/user.controller.js"></script>
<script type="text/javascript" src="/app/components/roles/app.roles.js"></script>
<script type="text/javascript" src="/app/components/roles/app.roles.routes.js"></script>
<script type="text/javascript" src="/app/components/roles/controllers/role.controller.js"></script>
</body>
</html>

app.js

(function() {
'use strict'; angular
.module('app', ["app.users",
"app.roles"
]); })();

app.users.js

(function() {
'use strict'; angular
.module('app.users', [
'ngRoute'
]); })();

app.users.routes.js

(function() {
'use strict'; angular
.module('app.users')
.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/users', {
templateUrl: '/app/components/users/views/user-list.tpl.html',
controller: 'UserController'
});
}]); })();

user-list.tpl.html

<h2>Users</h2>

user.controller.js

(function() {
'use strict'; angular
.module('app.users')
.controller('UserController', function() {
}); })();

The "use strict" Directive

The "use strict" directive is new in JavaScript 1.8.5 (ECMAScript version 5).

It is not a statement, but a literal expression, ignored by earlier versions of JavaScript.

The purpose of "use strict" is to indicate that the code should be executed in "strict mode".

With strict mode, you can not, for example, use undeclared variables.

AngularJS Best Practices: ngRoute的更多相关文章

  1. AngularJS 路由:ng-route 与 ui-router

    AngularJS的ng-route模块为控制器和视图提供了[Deep-Linking]URL. 通俗来讲,ng-route模块中的$routeService监测$location.url()的变化, ...

  2. AngularJS Best Practices: resource

    A factory which creates a resource object that lets you interact with RESTful server-side data sourc ...

  3. angularjs之插件ngRoute和ngAnimate

    使用ngRoute和ngAnimate配合使用,可以实现页面切换的效果. 如果有使用过swiper,就知道这个效果是怎么样的. 代码: <!DOCTYPE html> <html l ...

  4. AngularJS Best Practices: SEO

    Google can execute AJAX & JavaScript for indexing, you can read the below link for more detailed ...

  5. AngularJS Best Practices: ui-router

    ui-router is a 3rd-party module and is very powerful. It supports everything the normal ngRoute can ...

  6. AngularJS Best Practices: pretty urls

    By default, AngularJS will route URLs with a hashtag. For example: http://example.com/ http://exampl ...

  7. AngularJs练习Demo17 ngRoute

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  8. AngularJs练习Demo16 ngRoute

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  9. AngularJS Best Practices: ng-include vs directive

    For building an HTML template with reusable widgets like header, sidebar, footer, etc. Basically the ...

随机推荐

  1. topcoder SRM 622 DIV2 FibonacciDiv2

    关于斐波那契数列,由于数据量比较小, 直接打表了,代码写的比较戳 #include <iostream> #include <vector> #include <algo ...

  2. 关于vim插件

    本人比较喜欢amix它集成了很多插件. 1.mru.vim:用于打开最近使用过的文件 使用命令: :MRU     打开最近的文件列表 上下箭头可以移动关标 :o 在新窗口中打开文件 2.NERD T ...

  3. ACM 找点

    找点 时间限制:2000 ms  |  内存限制:65535 KB 难度:2   描述 上数学课时,老师给了LYH一些闭区间,让他取尽量少的点,使得每个闭区间内至少有一个点.但是这几天LYH太忙了,你 ...

  4. js-小效果-瀑布流

    <!doctype html><html><head><meta charset="utf-8"><title>无标题文 ...

  5. Redis_Spring与Jedis的集成

    首先不得不服Spring这个宇宙无敌的开源框架,几乎整合了所有流行的其它框架,http://projects.spring.io/spring-data/从这上面看,当下流行的redis.solr.h ...

  6. posix and system V IPC

    轉載自 http://www1.huachu.com.cn/read/readbook.asp?bookid=10104131 http://www1.huachu.com.cn/read/readb ...

  7. SpringMVC原理和框架

    SpringMVC工作原理 在上一篇章[spring]01_环境配置 中,我们演示了一个简单的HelloWorld工程. 本篇章重点讲述SpringMVC的基本工作原理,让大家进一步加深认识. 工作流 ...

  8. 用java页面下载图片

    try { //根据String形式创建一个URL对象 String filePath = materialProductWorks.getDownloadImageUrl(); URL url = ...

  9. LongListSelector with bindable SelectedItem

    using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using Microso ...

  10. web app 自适应方案总结 弹性布局之rem

    关于rem,主要参考文档 1.腾讯ISUX (http://isux.tencent.com/web-app-rem.html) 2.http://www.w3cplus.com/css3/defin ...