我正在使用角度1.6.4和节点6.1,我正在尝试将我在player-main组件中指定的简单数组加载到模板,但它没有正确加载。
angular.
module('player').
component('playerMain', {
templateUrl: '/player.php',
controller: function PlayListController() {
this.songs = [
{
id: 'one',
title: 'Rain',
artist: 'Drake',
url: 'http://www.schillmania.com/projects/soundmanager2/demo/_mp3/rain.mp3'
},
{
id: 'two',
title: 'Walking',
artist: 'Nicki Minaj',
url: 'http://www.schillmania.com/projects/soundmanager2/demo/_mp3/walking.mp3'
},
{
id: 'three',
title: 'Barrlping with Carl (featureblend.com)',
artist: 'Akon',
url: 'http://www.freshly-ground.com/misc/music/carl-3-barlp.mp3'
},
{
id: 'four',
title: 'Angry cow sound?',
artist: 'A Cow',
url: 'http://www.freshly-ground.com/data/audio/binaural/Mak.mp3'
},
{
id: 'five',
title: 'Things that open, close and roll',
artist: 'Someone',
url: 'http://www.freshly-ground.com/data/audio/binaural/Things%20that%20open,%20close%20and%20roll.mp3'
}
];
}
});
当模板网址被调用时,' player.php'快递路由器将其重定向到以下玉模板。
.container
.row
.col-md-12
h5 Songs
ul
li(ng-repeat='song in $ctrl.songs')
button(music-player='play', add-song='song') {( song.title )}
button(music-player='', add-song='song') +
button(play-all='songs') Play all
button(play-all='songs', data-play='false') Add all
hr
但即使ng-repeat确实迭代了数组5次,
{(song.title)}
没有得到评估,它只是将其打印为字符串。