重构了一下简书。angular

手痒:练手作品,只在移动端实现部分功能







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("!!!")
  })
});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值