发表于: 2017-06-02 23:56:02
2 1303
今天做了的事:
1.学会看后台接口文档(这回终于知道任务给的接口哪里是哪里了=。=)
2.将请求来的数据通过ng-repeat显示在页面上
3.使用filter按照接口文档里面的规则进行转换
明天要做的事:
学习一下自定义filter
学习一下ui-rooter
将以前任务改成ui-rooter
添加搜索和分页
今天遇到的问题:
POST和GET这两种方法在这两天的使用的过程中,我发现,GET不需要使用一个事件去触发,把他写在一个控制器下他就在进入这个页面的时候自动请求数据了。而POST则不行,需要通过点击等方式触发才可以执行。
ng-repeat跟ng-options很像,都有一写表达语句来控制渲染的规则,不过ng-repeat的更简单:
x in records
(key, value) in myObj
x in records track by $id(x)
代码如下:
angular.module('wifeBackstage',['ngRoute'])//模块,依赖ngroute
.config(['$routeProvider',function($routeProvider){
$routeProvider
.when('/',{templateUrl: 'welcome.html'})
.when('/articlelist',{templateUrl: 'articlelist.html'})
.when('/newadd',{templateUrl: 'newadd.html'})
// .otherwise({redirectTo:'welcome.html'});
}])
.controller('list',function ($scope,$http) {
// $scope.data=[];
$http({
method: "GET",
url: "/carrots-admin-ajax/a/article/search",
}).then(function successCallback(response) {
$scope.data = response.data.data.articleList;
})
});
// 点击事件
function getObvious () {
if (table.style.display==="none") {
table.style.display = "block";
}
else if (table.style.display === "block") {
table.style.display="none";
}
}
ng-repeat:
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th><b> ID</b></th>
<th><b>名称</b></th>
<th><b>类型</b></th>
<th><b>发布时间</b></th>
<th><b>修改时间</b></th>
<th><b>发布者</b></th>
<th><b>状态</b></th>
<th><b>操作</b></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in data">
<th><b>{{item.id}}</b></th>
<th><b>{{item.title}}</b></th>
<th><b>{{item.type}}</b></th>
<th><b>{{item.createAt|date:"yyyy-MM-dd HH:mm:ss"}}</b></th>
<th><b>{{item.updateAt|date:"yyyy-MM-dd HH:mm:ss"}}</b></th>
<th><b>{{item.author}}</b></th>
<th><b>{{item.status}}</b></th>
<th><b>{{item.order}}</b></th>
</tr>
</tbody>
</table>
</div>
感悟:我的傻同学怎么昨天没写日报
评论