Borykam sie teraz z takim problemem. Jest mozliwosc wyswietlenia kilku wynikow poprzez route param? Bo jak wiadomo, on bierze jakies id i wyswietla. A w moim pliku wyglada to tak.
[{"id":1,"idpost":1,"postname":"General Example","postsender":"General Example","postcont":"General Example"},{"id":3,"idpost":2,"postname":"Hobby Example","postsender":"Hobby Example","postcont":"Hobby Example"},{"id":5,"idpost":1,"postname":"Mu mu Cow Cow","postsender":"Mu mu Cow Cow","postcont":"Mu mu Cow Cow"},{"id":6,"idpost":2,"postname":"Mu mu Cow Cow2","postsender":"Mu mu Cow Cow2","postcont":"Mu mu Cow Cow"}]
Chce dawac a hrefy do idpost, a pozniej wszystkie wyniki np. z idpost1 wyswietlac i tak dalej. Nie jeden wynik tylko kilka wynikow o tym id. A oto moj kod:
Controller:
angular.module('myapp',[]).
config(function($routeProvider ){
$routeProvider.
when('/routeparam',{templateUrl:'../app/views/routeparam.php'}).
when('/routeparam/:idpost',{templateUrl:'../app/views/routeparamdetail.php',controller:'viewController'})
}).
controller('ctrl',['$scope','$http','$window', function($scope,$http,$window){
$http.get('http://localhost/laravel/public/demo').success(function(data){
$scope.information=data;
console.log($scope.information);
})
}]).
controller('viewController',['$scope','$routeParams',function($scope,$routeParams){
$scope.person=$scope.information[$routeParams.idpost]
}])
A to widok
<!doctype html>
<html lang="en" ng-app="myapp">
<head>
<meta charset="UTF-8">
<title>Laravel + Angular</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.5/angular.min.js"></script>
<!-- <script src="https://code.angularjs.org/1.1.5/angular-resource.min.js"></script> -->
<script src="../app/angular/app.js"></script>
</head>
<body>
<div class="container">
<div ng-controller="ctrl">
<div ng-include="'../app/views/navbartop.html'">
</div>
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<div class="container">
<ng-view></ng-view>
</div>
</div>
</div>
</body>
</html>
routeparam.php
<div ng-repeat="n in information">
<a href="#/routeparam/{{n.idpost}}">{{n.postname}}</a>{{n.idpost}}
</div>
routeparamdetail.php
<div ng-repeat="e in person ">
{{e.postname}}
</div>