- 安装Angular
- 安装ui-router
- 安装normalize.css
- 安装JQuery
- 创建基础文件及基础页面
npm install jquery angular angular-ui-router normalize-css
API
Route::get('/', function () {
return view('welcome');
});
view在resources中的views中
<!doctype html>
<html lang="zh" ng-app="bihu">
<head>
<meta charset="UTF-8">
<title>乐乎</title>
<link rel="stylesheet" href="node_modules\normalize-css\normalize.css">
<link rel="stylesheet" href="css\base.css">
</head>
<body>
<div ng-controller="TestController">
[: name :]
</div>
<div>
[: name :]
</div>
<script src="node_modules\jquery\dist\jquery.js"></script>
<script src="node_modules\angular\angular.js"></script>
<script src="node_modules\angular-ui-router\release\angular-ui-router.js"></script>
<script src="js\base.js"></script>
</body>
</html>
;(function(){
'use strict';
angular.module('bihu',[])
//避免angular和larvael冲突{{}},配置,依赖
.config(function($interpolateProvider){
$interpolateProvider.startSymbol('[:');
$interpolateProvider.endSymbol(':]');
})
.controller('TestController',function($scope){
$scope.name = 'Bob';
})
})();
Ag路由好处:网页内容布局刷新,流畅
ui-router路由的建立:
;(function(){
'use strict';
angular.module('bihu',['ui.router'])
//避免angular和larvael冲突{{}},配置,依赖
.config(function($interpolateProvider,$stateProvider,$urlRouterProvider){
$interpolateProvider.startSymbol('[:');
$interpolateProvider.endSymbol(':]');
$urlRouterProvider.otherwise('/home');
// 路由规则
$stateProvider
.state('home',{
url: '/home',
templateUrl:'home.tpl'
})
.state('login',{
url: '/login',
templateUrl:'login.tpl'
})
})
})();
<div class="navbar">
<a href="" ui-sref="home">首页</a>
<a href="" ui-sref="login">登陆</a>
</div>
<div>
<div ui-view></div>
</div>
<script type="text/ng-template" id="home.tpl">
<div>
<h1>首页</h1>
</div>
</script>
<script type="text/ng-template" id="login.tpl">
<div>
<h1>登陆</h1>
</div>
</script>
问题模块:
- form不要写在a标签里面,因为这样a的超链接属性会覆盖掉form的点击提交