你能不能在某个地方发布一个例子,如何在一个页面上控制来自父控制器的ng-repeat产生的两个兄弟视频:"播放",播放左","暂停"等:[http://plnkr.co/edit/bvTvBNo3B4yydbzIOraX]。我知道如何使用jQuery,但不是使用视频:
// initializers/current-user.js
import Ember from 'ember';
import Session from 'simple-auth/session';
export default {
name: 'current-user',
before: 'simple-auth',
initialize: function(container, application) {
Session.reopen({
setCurrentUser: function() {
let appController = container.lookup("controller:application");
// don't know how to check if the app is already ready
try{
application.deferReadiness();
console.log('deferred');
}catch(e){}
if(this.get('isAuthenticated')) {
console.log('running the isAuthenticated obs');
let store = container.lookup('store:main');
let _this = this;
return store.find('user', 'me').then((user) => {
// set the current user to be used on the session object
this.set('currentUser', user);
}).then(function(){
// set the store for the current user
store.find('store', {user: _this.get('currentUser.id')}).then(function(data) {
_this.set('myStore', data.get('firstObject'));
application.advanceReadiness();
});
})
}
}.observes('isAuthenticated')
});
}
};
// controllers/application.js
export default Ember.Controller.extend({
myStore: Ember.computed(function(){
// return the store object that is associated with the current user
if(this.get('session.isAuthenticated')){
if(this.get('session.myStore')){
return this.get('session.myStore');
}else{
console.log(this.get('session.currentUser'));
// this is where the problem is. The session.currentUser is not populated yet.
this.get('store').find('store', {user: this.get('session.currentUser.id')}).then(function(data) {
this.get('session').set('myStore', data.get('firstObject'));
return this.get('session.myStore');
});
}
}
}),
});
// routes/phone-numbers.js
export default Ember.Route.extend({
setupController: function(controller, model){
this._super(controller, model);
let myStoreId = this.controllerFor('application').get('myStore.id');
if(!myStoreId){
console.log(this.get('session.currentUser'));
// there is no currentUser set on the session after login
}else{
this.store.find('store-phone-number', {'store': myStoreId}).then(function(numbers){
controller.set('numbers', numbers);
});
}
},
});