AngularJS Display 1 Post in New Page

后端 未结 2 1657
孤城傲影
孤城傲影 2021-01-26 12:03

I want to display only Test Post 1 in next html page titleDetails.html when user clicks Test Post 1 in index.html

2条回答
  •  不知归路
    2021-01-26 13:03

    Hope this following steps work for you
    Pass post object to titleDetail() function.
    In index.html

    {{ post.title }} 
    

    In function assign post to $rootScope variable

    $scope.titleDetails = function(post) {
       $rootScope.postDetail = post;
    }
    

    Now your titleDetail.html page controller:

    $scope.post = $rootScope.postDetail;
    

提交回复
热议问题