Created
January 7, 2015 10:06
-
-
Save zhangskills/c4147deb777ef23159f1 to your computer and use it in GitHub Desktop.
angularjs
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
1 |
基本index.js结构
angular.module('my-app', ['ui.router','restangular'])
.config(['$stateProvider', '$urlRouterProvider', '$locationProvider',
function($stateProvider, $urlRouterProvider, $locationProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider.state('index', {
url: '/',
templateUrl: 'public/app/index.html'
}).state('blog', {
abstract: true,
url: '/blog',
templateUrl: 'public/app/blog/index.html'
}).state('blog.list', {
url: '/list',
templateUrl: 'public/app/blog/list.html',
controller: 'blogListController'
}).state('blog.show', {
url: '/:id',
templateUrl: 'public/app/blog/show.html',
controller: 'blogShowController'
});
$locationProvider.html5Mode(true);
}
])
.controller('blogListController', function($scope,Restangular) {
Restangular.all('api/blog/list').getList().then(function(list){
$scope.list = list;
});
})
.controller('blogShowController', function($scope, $stateParams) {
$scope.id = $stateParams.id;
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
基本index.html结构