手痒:练手作品,只在移动端实现部分功能
var app = angular.module('jianshu', []); app.filter('showAsHtml',function ($sce) { return function(input){ return $sce.trustAsHtml(input); } }) app.controller("index_m", function ($scope,$http) { //当前的分类 // $scope.categoryNow = 0; $scope.categoryNow = 1; // 获取分类列表 $http.get('/ports/jianshu/category.do').success(function (res) { if (res.code == 100) { $scope.categoryList = res.data; // $scope.categoryList.unshift({"categoryId":0,"name":"默认"}); $scope.setCategoryNow = function (now) { $scope.categoryNow = now; getArtcleList() } } else { alert('错了' + res.code); } }).error(function () { alert('错误'); }); // 文章列表 function getArtcleList() { $http.get('/ports/jianshu/articles/' + $scope.categoryNow + '/' + $scope.nowPage + '.do').success(function (res) { if(res.code==100){ $scope.menuList=res.data; }else { alert("失败"+res.code) } }).error(function () { alert("!"); }) } // 当前第几页 $scope.nowPage = 1; }); app.controller('article_m',function($scope,$http){ var id=location.search.substring(1).split('=')[1] $http.get('/ports/jianshu/articleInfor/'+id+'.do').success(function(res){ if (res.code == 100) { $scope.articleInfo=res.data; }else { alert('错了' + res.code); } }).error(function(){ alert("!!!") }) });