Reputation: 2912
So I started using EmberJS today.
// js/main.js
require.config({
baseUrl:'js/',
paths:{
ember: 'libs/emberjs/ember-0.9.8.1',
text: 'libs/require/text',
}
});
// Start the main app logic.
requirejs([
'ember',
'app/controller/users'
],
function(ember, UsersController) {
App = Em.Application.create();
console.log(UsersController); // undefined
}
);
// My Controller
// js/app/controller/users.js
define('app/controllers/users', [
'text!app/views/users/index.handlebar'
],
function( UsersIndexTemplate ) {
return Ember.Object.create({
indexView: Ember.View.create({
template: Ember.Handlebars.compile( UsersIndexTemplate )
}),
// Activates the views and other initializations
init: function() {
this.get( 'indexView' ).appendTo( '#content' );
}
});
});
My question here is, why is the Controller undefined? I built this while reading the TodoMVC example and don't udnerstand why this doesn't work the same way.
Upvotes: 1
Views: 472
Reputation: 2912
I found the answer, it's just too simple.
To invoke the main app logic I need to use require()
NOT requirejs()
Upvotes: 2