ui-router has the powerful ability to define abstract states, or states that can't be navigated to, but are useful for defining a set of states with shared properties.

angular.module("auth", [])

    .config(function ($stateProvider) {

      $stateProvider
.state('in', {
url: '/in',
template: '<h1>Sign In</h1>' +
'<button class="btn btn-primary" ng-click="signIn()">Sign In Now</button>'
})
.state('up', {
url: '/up',
template: '<h1>Sign Up for a Free Account.</h1>'
})
});

For example, the sign in page an sign up page share the same content. Those content can be written into the abstract ui router.

angular.module("auth", [])

    .config(function ($stateProvider) {

      $stateProvider
.state('sign', {
abstract: true,
url: '/sign',
template: '<a ui-sref=".in">Sign In</a>' +
'<a ui-sref=".up">Sign Up!</a>' +
'<ui-view/>',
controller: function($scope, authService){
$scope.signIn = function(){
authService.signIn();
}
},
resolve: {},
data: {},
onEnter: function(){},
onExit: function(){}
})
.state('sign.in', {
url: '/in',
template: '<h1>Sign In</h1>' +
'<button class="btn btn-primary" ng-click="signIn()">Sign In Now</button>'
})
.state('sign.up', {
url: '/up',
template: '<h1>Sign Up for a Free Account.</h1>'
})
});

[AngularJS] ui-router: Abstract States的更多相关文章

  1. [转]AngularJS+UI Router(1) 多步表单

    本文转自:https://www.zybuluo.com/dreamapplehappy/note/54448 多步表单的实现   在线demo演示地址https://rawgit.com/dream ...

  2. angularJS ui router 多视图单独刷新问题

    场景:视图层级如下 view1 --view11 --view111 需求:view11的一个动作过后,单独刷新view12 解决方式:修改层级设计 view1 --view11 --view111 ...

  3. Angularjs ui router,路由嵌套 父controller执行问题

    解决方式来源:https://stackoverflow.com/questions/25316591/angularjs-ui-router-state-reload-child-state-onl ...

  4. AngularJS 使用 UI Router 实现表单向导

    Today we will be using AngularJS and the great UI Router and the Angular ngAnimate module to create ...

  5. angular 的ui.router 定义不同的state 对应相同的url

    Angular UI Router: Different states with same URL? The landing page of my app has two states: home-p ...

  6. [转]AngularJS 使用 UI Router 实现表单向导

    本文转自:http://www.oschina.net/translate/angularjs-multi-step-form-using-ui-router 今天我们将使用AngularJs和伟大的 ...

  7. angularjs ngRoute和ui.router对比

    ngRoute模块是angularjs自带的路由模块,ui.router是一个第三方路由模块,接下来将对两者进行一个对比: ng-router(angular-router.js) ng-view n ...

  8. 【原创】ui.router源码解析

    Angular系列文章之angular路由 路由(route),几乎所有的MVC(VM)框架都应该具有的特性,因为它是前端构建单页面应用(SPA)必不可少的组成部分. 那么,对于angular而言,它 ...

  9. [AngularJS] Consistency between ui-router states and Angular directives

    ui-router's states and AngularJS directives have much in common. Let's explores the similarities bet ...

随机推荐

  1. 关于“心脏出血”漏洞(heartbleed)的理解

    前阵子“心脏出血”刚发生的时候读了下源代码,给出了自己觉得比较清楚的理解.   -------------------------穿越时空的分割线--------------------------- ...

  2. LeetCode题解——Regular Expression Matching

    题目: 正则表达式的匹配,'.'能匹配任何一个字符,'*'之前必须有一个字符,两个结合起来表示之前那个字符出现0到无穷次. 解法: 一定要注意'*'必须结合前面的字符一起使用. 代码: class S ...

  3. 关于如果修改 ie 浏览器 文本模式

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/html4/stric ...

  4. BestCoder Round #76 解题报告

    DZY Loves Partition [思路] 贪心 [代码] #include <iostream> using namespace std; typedef long long ll ...

  5. Tomcat线程池,更符合大家想象的可扩展线程池

    因由 说起线程池,大家可能受连接池的印象影响,天然的认为,它应该是一开始有core条线程,忙不过来了就扩展到max条线程,闲的时候又回落到core条线程,如果还有更高的高峰,就放进一个缓冲队列里缓冲一 ...

  6. Android实例-屏幕操持常亮(XE8+小米2)

    相关资料: http://www.bubuko.com/infodetail-163304.html 结果: 1.打开权限Wake lock为True. 第三方单元: unit Android.JNI ...

  7. SpringDataMongoDB介绍(一)-入门

    SpringDataMongoDB介绍(一)-入门 本文介绍如何应用SpringDataMongoDB操作实体和数据库,本文只介绍最基本的例子,复杂的例子在后面的文章中介绍. SpringDataMo ...

  8. javascript实现队列功能

  9. animate平滑回到顶部

    Js: //回到顶部 $(".totop").click(function () { $("body,html").animate({scrollTop: 0} ...

  10. ios 调试

    http://www.cnblogs.com/weilaikeji/p/3306597.html http://www.cnblogs.com/Twisted-Fate/p/4760156.html ...