1. Install ui-route, include js file in html and add dependence in js file.

bower install angular-ui-router
<script src="bower_components/angular-route/angular-route.min.js"></script>
angular.module('Eggly', [
'ui.router',
'categories',
'categories.bookmarks'
])

2. Add config() to the app, inject with $stateProvider.

angular.module('Eggly', [
'ui.router',
'categories',
'categories.bookmarks'
]) //inject the stateProvider
.config(function($stateProvider){
$stateProvider
.state('eggly', {
url:'/', //point to the root url
templateUrl: 'app/categories/categories.tmpl.html',
controller: 'MainCtrl'
})
;
})

3. add ui-view directive to the html

        <div class="container-fluid" ui-view>

        </div>

4. Add content to the

categories.tmpl.html
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<a ng-click="setCurrentCategory(null)"><img class="logo" src="assets/img/eggly-logo.png"></a>
<ul class="nav nav-sidebar">
<li ng-repeat="category in categories" ng-class="{'active':isCurrentCategory(category)}">
<a ng-click="setCurrentCategory(category)">
{{category.name}}
</a>
</li>
</ul>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<div ng-class="{active: isSelectedBookmark(bookmark.id)}" ng-repeat="bookmark in bookmarks | filter:{category:currentCategory.name}">
<button type="button" class="close" ng-click="deleteBookmark(bookmark)">&times;</button>
<button type="button" class="btn btn-link" ng-click="setEditedBookmark(bookmark);startEditing();" ><span class="glyphicon glyphicon-pencil"></span>
</button>
<a href="{{bookmark.url}}" target="_blank">{{bookmark.title}}</a>
</div>
<hr/>
<!-- CREATING -->
<div ng-if="shouldShowCreating()">
<button type="button" class="btn btn-link" ng-click="startCreating()">
<span class="glyphicon glyphicon-plus"></span>
Create Bookmark
</button>
<form class="create-form" ng-show="isCreating" role="form" ng-submit="createBookmark(newBookmark)" novalidate>
<div class="form-group">
<label for="newBookmarkTitle">Bookmark Title</label>
<input type="text" class="form-control" id="newBookmarkTitle" ng-model="newBookmark.title" placeholder="Enter title">
</div>
<div class="form-group">
<label for="newBookmarkURL">Bookmark URL</label>
<input type="text" class="form-control" id="newBookmarkURL" ng-model="newBookmark.url" placeholder="Enter URL">
</div>
<button type="submit" class="btn btn-info btn-lg">Create</button>
<button type="button" class="btn btn-default btn-lg pull-right" ng-click="cancelCreating()">Cancel</button>
</form>
</div>
<!-- EDITING -->
<div ng-show="shouldShowEditing()">
<h4>Editing {{editedBookmark.title}}</h4> <form class="edit-form" role="form" ng-submit="updateBookmark(editedBookmark)" novalidate>
<div class="form-group">
<label>Bookmark Title</label>
<input type="text" class="form-control" ng-model="editedBookmark.title" placeholder="Enter title">
</div>
<div class="form-group">
<label>Bookmark URL</label>
<input type="text" class="form-control" ng-model="editedBookmark.url" placeholder="Enter URL">
</div>
<button type="submit" class="btn btn-info btn-lg">Save</button>
<button type="button" class="btn btn-default btn-lg pull-right" ng-click="cancelEditing()">Cancel</button>
</form>
</div>
</div>
</div>

5. When visiting the page, url should change accordingly, otherwise nothing will show.

old url:
http://localhost:63342/eggly/index.start.html
new url:
http://localhost:63342/eggly/index.start.html#/

Read More:

https://github.com/angular-ui/ui-router

http://angular-ui.github.io/ui-router/site/#/api/ui.router

https://github.com/eggheadio/egghead-angularjs-eggly-architecture/tree/03-basic-state-ui-router

[Angular-Scaled web] 3. Basic State with ui-router的更多相关文章

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

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

  2. ngRoute 与ui.router区别

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

  3. ngRoute 和 ui.router 的使用方法和区别

    在单页面应用中要把各个分散的视图给组织起来是通过路由机制来实现的.本文主要对 AngularJS 原生的 ngRoute 路由模块和第三方路由模块 ui.router 的用法进行简单介绍,并做一个对比 ...

  4. angular : $location & $state(UI router)的关系

    次序:angular 的 location会先跑 $rootScope.$on("$locationChangeStart", function (scope, newUrl, o ...

  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. vue,react,angular三大web前端流行框架简单对比

    常用的到的网站 vue学习库: https://github.com/vuejs/awesome-vue#carousel (json数据的格式化,提高本地测试的效率) json在线编辑: http: ...

  7. 混合开发 Hybird Ionic Angular Cordova web 跨平台 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  8. angular ui.router 路由传参数

    angular已经用了一段时间了,最近在做路由,做一下笔记. 路由跳转的时候进行穿参 ui.router方式 <a ui-sref="edit({id:5})"> 编辑 ...

  9. Portswigger web security academy:Clickjacking (UI redressing)

    Portswigger web security academy:Clickjacking (UI redressing) 目录 Portswigger web security academy:Cl ...

随机推荐

  1. http请求,HttpClient,调用短信接口

    项目中安全设置找回密码的功能,需要通过发送短信验证绑定手机,通过绑定的手机号验证并重新设置密码. 因为项目是通过maven管理的,所以需要在pom.xml文件中引入jar包, maven引入的jar包 ...

  2. PlayMaker的Transition和Global Transition

    PlayMaker的Transition和Global Transition   在PlayMaker中,Transition是指从一个状态(State)过渡到另外一个状态.它由事件(Event)实现 ...

  3. 洗牌问题 FZU - 1062 (传说中的思路题,hhh)

    设2n张牌分别标记为1, 2, -, n, n+1, -, 2n,初始时这2n张牌按其标号从小到大排列.经一次洗牌后,原来的排列顺序变成n+1, 1, n+2, 2, -, 2n, n.即前n张牌被放 ...

  4. BZOJ1038 瞭望塔

    学习了半平交面. 我这里写的是训练指南中的双端队列,每次判断是否删去更优然后更新. 看hzwer中有一处不太明白就是为何要将两段加入队列 后来对拍出错才知道是因为精度,当两线重合时他们叉积返回值是一个 ...

  5. 线段树--codevs 1690 开关灯

    codevs 1690 开关灯 USACO  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题目描述 Description YYX家门前的街上有N(2& ...

  6. bzoj4567 背单词

    Description Lweb 面对如山的英语单词,陷入了深深的沉思,“我怎么样才能快点学完,然后去玩三国杀呢?”.这时候睿智 的凤老师从远处飘来,他送给了 Lweb 一本计划册和一大缸泡椒,他的计 ...

  7. poj 2828 buy Tickets 用线段树模拟带插入的队列

    Buy Tickets Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2 ...

  8. MySQL主库切换那些事

    最近连续经历了机架掉电和交换机挂掉,着实切了不少主库,虽然过程心惊胆跳,但是也算是上过战场,经过了实战演习,相信TEAM中的小伙伴们对于切主库已经可以驾轻就熟了. MySQL的主库切换也属于DBA的一 ...

  9. JavaScript Diagramming

    JavaScript Diagramming Optensity

  10. WICED™ <SMART> Software Development Kit

    WICED™ Software Development Kit The WICED™ SDK includes the tools and software needed to create Wi-F ...