Ag和Laravel开发仿知乎笔记-前端

  • 安装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的点击提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值