I am writing code to show a simple list of users. And when clicking on a user I want to get to a view with information about that user. I have reached to the point where I show the user in a list and when I click a user I get to the view I have created. My question is where to add the views for all the users and how to show them correctly:
Here is what I got until now:
UsersCtrl.$inject = ['$scope'];
function EventsCtrl($scope {
$scope.events = [
{ Name: 'User1', id: 1, image: 'logo1.jpg' },
{ Name: 'User2', id: 2, image: 'logo2.jpg' },
];
}
UsersCtrl.$inject = ['$scope'];
function UserCtrl($scope, '$routeParams') {
$scope.userId = $routeParams.userId;
}
And in app.js :
.state('app.users', {
url: "/users",
views: {
'appScreen': {
templateUrl: "users.html",
controller: 'UsersCtrl'
}
}
})
.state('app.userV', {
url: "/users/:usersId",
views: {
'appScreen': {
templateUrl: "user.html",
controller: 'UsersCtrl'
}
}
})
and in my Index.html
<script type="text/ng-template" id="users.html">
<ion-view view-title="Users">
<ion-content>
<div class="list">
<a class="item item-thumbnail-left" ng-repeat="user in users" ui-sref="app.userV({userId: user.id})">
<img ng-src="{{user.image }}">
<h2>{{user.Name}}</h2>
</a>
</div>
</ion-content>
</ion-view>
</script>
<script type="text/ng-template" id="user.html">
<ion-view view-title="User">
<ion-content>
<div class="list card">
<div class="item item-avatar">
<img src="User1.jpg">
<h2>User 1 </h2>
</div>
<div class="item item-body">
<img class="full-image" src="/Content/img/P9090246.jpg">
<p>
This is a "Facebook" styled Card. The header is created from a Thumbnail List item,
the content is from a card-body consisting of an image and paragraph text.
</p>
</div>
</div>
</ion-content>
</ion-view>
</script>