This may seem trivial, but I have been unsuccessful at getting this to work. I have used UserApp.io successfully for user/authentication management. I recently created an ember app using ember-cli, but I am unable to get the two to work together despite ember being supported by UserApp.io. Here are there instructions (integrating with ember without cli).
https://github.com/userapp-io/userapp-ember
Here is a snippet:
Include the UserApp JavaScript library and this Ember module in your index.html. Be sure to add them before your app.js file.
<script src="https://app.userapp.io/js/userapp.client.js"></script>
<script src="https://app.userapp.io/js/ember-userapp.js"></script>
(You can also install the module with bower: $ bower install userapp-ember)
Initiate the module
Add this code above App = Ember.Application.create(); in app.js with your App Id.
Ember.Application.initializer({
name: 'userapp',
initialize: function(container, application) {
Ember.UserApp.setup(application, { appId: 'YOUR-USERAPP-APP-ID' });
}
});
Because I am using ember-cli I have created a file called userapp.js in an initializers folder which has the following code:
import Ember from 'ember';
export default {
name: 'userapp',
initialize: function(container, application) {
Ember.UserApp.setup(application, {
appId: 'USERAPP-ID-INSERTED-HERE',
loginRoute: 'login',
indexRoute: 'index',
heartbeatInterval: 20000,
usernameIsEmail: false
});
}
};
When I run my app I get the following error:
Uncaught TypeError: Cannot read property 'setup' of undefined
I feel like this is something simple/stupid, but for the life of me I cannot figure this one out.
It seems ember-userapp.js is not getting included in ur app. If you are using bower to install it, edit the Brocfile.js to include the lib like
app.import('bower_components/userapp-ember/ember-userapp.js');
Its mentioned here http://ember-cli.com/#standard-non-amd-asset
Related
I recently moved from ember 1.x to 2.6. I am not able to use addObject/pushObject like i used to.
Ember : 2.6.2
jQuery : 2.2.4
import Ember from 'ember';
export default Ember.Controller.extend({
test: ['sibi', 'john'],
init: function() {
this.get('test').pushObject('sebastian');
}
});
This throws an error like pushObject is not a function. What is the workaround? Thank you.
The extend prototypes option was false for some reason.
You can read more about disabling prototype extensions in the guide.
EmberENV: {
EXTEND_PROTOTYPES: {
Array: true
}
}
Thank you!
Check your package.json against ember-disable-prototype-extensions.
If your project is an addon project it had beed added by ember-cli. And you should live with it. (Use Ember.A whenever you need an Ember array.)
If your project is an application project, just remove this addon.
I created a sample ember-cli project using ember 1.13.5. I create one component and a dummy integration test. It runs just fine.
import { moduleForComponent, test } from 'ember-qunit';
moduleForComponent('selected-product', 'Integration | Component | selected product', {
integration: true
});
test('amount', function(assert) {
assert.equal(100.00, 100.00);
});
I then update my ember version to 2.0.0-beta.3 in my bower.json file, run the tests, and receive an immediate error:
TypeError: 'undefined' is not an object (evaluating 'Ember.View.extend')
TypeError: 'undefined' is not an object (evaluating 'this.cache.subject')
There is literally nothing else custom in my projet. I just generated it. I realize it's beta software and not quite ready for primetime, but if anyone knows of a simple configuration change, I would appreciate it. I'm using ember-cli version 1.13.1.
You'll need to the latest version of ember-qunit, v.0.4.4 as of today, as ember-2.0.0-beta.3 compatibility was added in this commit. The version of ember-cli you are using does not come with this version of ember-qunit.
I just started working with Ember-CLI 0.0.36 and I'm stuck with the Gravatar example code from the Ember.js homepage.
I did
> bower install --save JavaScript-MD5
> ember generate component gravatar-image
Brocfile.js
[...]
app.import('vendor/JavaScript-MD5/js/md5.js');
[...]
app/components/gravatar-image.js
import Ember from 'ember';
export default Ember.Component.extend({
size: 200,
email: '',
gravatarUrl: function() {
var email = this.get('email'),
size = this.get('size');
return 'http://www.gravatar.com/avatar/' + md5(email) + '?s=' + size;
}.property('email', 'size')
});
After starting ember server I'll get the following error message:
xyz/components/gravatar-image.js: line 11, col 48, 'md5' is not defined.
1 error
How can I tell the component to use JavaScript-MD5?
To get this to work I used:
bower install blueimp-md5 --save-dev
and added import in Brocfile.js
app.import('bower_components/blueimp-md5/js/md5.js');
then add "md5" to predef array as mentioned by Oliver to suppress md5 warning.
JavaScript-MD5 does't export any AMD-Modules, if I see it right. But it defines window.md5. So your app.import will include it in vendor.js and you can call window.md5 in the component.
That's just a jshint linter message.
Open your .jshintrc file, add "md5" to the "predef" object and you are fine.
You might need to install the ember-cli-md5 package. This will install all the required dependencies in your node modules.
Use this npm install --save-dev ember-cli-md5 to install ember-cli-md5.
Once installed you will need to generate md-5 which will install the browser package via bower.
Use this to generate md-5 ember generate md-5.
So, you need to perform following two steps:-
npm install --save-dev ember-cli-md5
ember generate md-5
I've recently upgraded from ember-cli 0.0.36 to 0.0.37 and have been struggling to import ember-data. Although seemingly simple, it's not working for me. In the Brocfile.js, the old import was
app.import({
development: 'vendor/ember-data/ember-data.js',
production: 'vendor/ember-data/ember-data.prod.js'
});
This was modified to comply with the new syntax:
app.import('vendor/ember-data/ember-data.js', { exports: { ember: ['default'] } });
however, I get the following error:
app.import(vendor/ember-data/ember-data.js) - Passing modules object is deprecated. Please pass an option object with modules as export key (see http://git.io/H1GsPw for more info).
I'm not sure how to proceed with this one so any help is much appreciated.
The new syntax is detailed here
As mentioned in the deprecated message this is the new syntax.
app.import({
development: 'vendor/ember-data/ember-data.js',
production: 'vendor/ember-data/ember-data.prod.js'
}, {
exports: {
'ember-data': ['default']
}
});
This error message was the result of leftovers from the old ember-cli-ember-data shim which was set to version 0.0.4 in the package.json file. I've changed it to 0.1.0 which is the latest as of this writing, removed (deleted) the old ember-cli-ember-data directory from the node_modules package directory and reran npm install. This resulted in the warning message disappearing.
I'm trying to migrate an ember app to use the ember app-kit. The code requires the accounting.js library. In the pre-app-kit version the file was loaded via a script tag in index.html
<script src="http://cdnjs.cloudflare.com/ajax/libs/accounting.js/0.3.2/accounting.min.js"></script>
and accessed in the views through the global namespace
App.MoneyField= Em.TextField.extend({
init: function() {
this._super();
var value = accounting.formatMoney(this.get("money") / 100, '');
this.set('value', value);
};
// other functions omitted
});
In the app-kit version, I've included accounting.js as a bower dependency. In bower.json:
{
"name": "ember-app-kit",
"dependencies": {
"handlebars": "~1.1.2",
"jquery": "~1.9.1",
"qunit": "~1.12.0",
"ember": "~1.4.0-beta.2",
"ember-data": "~1.0.0-beta.6",
"ember-resolver": "git://github.com/stefanpenner/ember-jj-abrams-resolver.git#master",
"ic-ajax": "~0.3.0",
"ember-testing-httpRespond": "~0.1.1",
"accounting":"~0.3.2"
},
"resolutions": {
"ember": "~1.4.0-beta.2"
}
}
When I try to build the app, it gives the error
W117: 'accounting' is not defined.
I understand why this is and know I need some sort of import accounting from ... statement.
How do I import a package installed via bower as an ES6 module?
I know that this was asked a few months ago, but since then, Ember App Kit has been succeeded by ember-cli, and this provides a very straight forward means to access either bower or npm dependencies.
Non-AMD asset
AMD asset
With regards to being accessed as ES6 modules:
Non-AMD assets cannot be accessed as an ES6 module, you simply access them through the global variable that they export.
e.g. moment
AMD assets, on the other hand, can be accessed through the ES6 import syntax
e.g. import { raw as icAjaxRaw } from 'ic-ajax';
Worth also mentioning, that ember-cli supports an add-on system now, which can make importing these things as simple as adding them to the package.json of your project. Some of the more popular libraries already have ember-cli addons for them. This post describes how you can write your own.