I am new to ionic framework and also to angularjs. I am trying to understand how does list items get mapped to app.single. In other example I found use of "list.item" for parent "list" state, but that didnt work for me (egghead.io tutorial).
I am using basic ionic app with sidemenu.
Can someone please explain how is app.single getting mapped to playlist item?
我是離子框架的新手,也是angularjs的新手。我試圖了解列表項如何映射到app.single。在其他示例中,我發現使用“list.item”作為父“list”狀態,但這對我沒有用(egghead.io教程)。我正在使用帶有sidemenu的基本離子應用程序。有人可以解釋一下app.single如何映射到播放列表項?
playlists.html:
<ion-view view-title="Playlists">
<ion-content>
<ion-list>
<ion-item ng-repeat="playlist in playlists" href="#/app/playlists/{{playlist.id}}">
{{playlist.title}}
</ion-item>
</ion-list>
</ion-content>
</ion-view>
playlist.html
<ion-view view-title="Playlist">
<ion-content>
<h1>Playlist</h1>
</ion-content>
</ion-view>
controller.js
.controller('PlaylistsCtrl', function($scope) {
$scope.playlists = [
{ title: 'Reggae', id: 1 },
{ title: 'Chill', id: 2 },
{ title: 'Dubstep', id: 3 },
{ title: 'Indie', id: 4 },
{ title: 'Rap', id: 5 },
{ title: 'Cowbell', id: 6 }
];
})
.controller('PlaylistCtrl', function($scope, $stateParams) {
});
app.js
.state('app.playlists', {
url: "/playlists",
views: {
'menuContent': {
templateUrl: "templates/playlists.html",
controller: 'PlaylistsCtrl'
}
}
})
.state('app.single', {
url: "/playlists/:playlistId",
views: {
'menuContent': {
templateUrl: "templates/playlist.html",
controller: 'PlaylistCtrl'
}
}
});
2
In your playlists.html, there's a html tag which gives url to target template for each playlist items.
在您的播放列表中,有一个html标记,用于为每个播放列表项目提供目标模板的网址。
href="#/app/playlists/{{playlist.id}}"
So, once a user taps on an item in current list, he will get redirected to "/app/playlists/{{playlist.id}}" page.
因此,一旦用户点击当前列表中的项目,他将被重定向到“/app/playlists/{{playlist.id}}”页面。
And then, please kindly focus on app.js which links each controller to desired url.
然后,请关注app.js,它将每个控制器链接到所需的URL。
url: "/playlists/:playlistId",
This is the part where your 'app.single' state is linked to each playlist item. In this case '/app' is omitted by abstract param of 'app' state definition.
这是您的'app.single'状态链接到每个播放列表项的部分。在这种情况下,“app”状态定义的抽象参数省略了“/ app”。
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2015/02/03/f0f35c70e6699f441694d8bf6cc1235a.html。