Created
May 23, 2013 16:28
-
-
Save shinofara/5637372 to your computer and use it in GitHub Desktop.
【メモ】【AngularJSのススメ】URLに応じて部分的に更新を行う方法(ルーティング)に関して ref: http://qiita.com/items/3f904e73a6eb1f929acd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
when("/hoge", { | |
when("/hoge/:id", { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module("app", []). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-app="app"> | |
<a href="http://xxxxx/hoge/123">有効リンク</a> | |
<div ng-view></div> | |
<a href="http://xxxxx/hoge/1234567">有効リンク</a> | |
</div> | |
<a href="http://xxxxx/hoge/123">無効リンク</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 相対パスをbaseで指定した場所から始める --> | |
<base href="/hoge/" /> | |
when("/", { | |
when("/:id", { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$locationProvider.html5Mode(true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html ng-app="app"> | |
<head> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js"></script> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular-resource.min.js"></script> | |
<script> | |
angular.module("app", []). | |
config(["$routeProvider", '$locationProvider', function($routeProvider,$locationProvider) { | |
//$locationProvider.hashPrefix('!'); | |
$locationProvider.html5Mode(true); | |
$routeProvider. | |
when("", { | |
// テンプレート文字列を指定 | |
templateUrl: '/template/teacher/index.html', | |
// テンプレートにバインドするコントロールの名前を指定 | |
controller: MainCtrl | |
}). | |
when("/:id", { //任意の文字列の場合 | |
/* 省略 */ | |
}) | |
.otherwise({redirectTo: '/'}); | |
}]); | |
</script> | |
</head> | |
<body> | |
<div ng-view>ここにテンプレートが挿入されるよ。</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment