dimanche 28 août 2016

Ember: Build Error Unexpected token

I am following tutorial try codes below

controller index.js

import Ember from 'ember';

export default Ember.Controller.extend({
    emailAddress: '',

    isValid: Ember.computed.match('emailAddress', /^.+@.+\..+$/),
    isDisabled: Ember.computed.not('isValid')

    actions: {
        saveInvitation() {
            alert(`Saving of the following email address is in progress: ${this.get('emailAddress')}`);
            this.set('responseMessage', `Thank you! We've just saved your email address: ${this.get('emailAddress')}`);
            this.set('emailAddress', '');
        }
    }
});

index.hbs

<div class="jumbotron text-center">
    <h1>Coming Soon</h1>

    <br/><br/>

    <p>Don't miss our launch date, request an invitation now.</p>

    <div class="form-horizontal form-group form-group-lg row">
        <div class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-1 col-md-5 col-md-offset-2">
            
        </div>
        <div class="col-xs-10 col-xs-offset-1 col-sm-offset-0 col-sm-4 col-md-3">
            <button class="btn btn-primary btn-lg btn-block" disabled= >Request invitation</button>
        </div>

    </div>
    
    <div class="alert alert-success"></div>
    

    <br/><br/>
</div>

What I expected is If I click on the button, the saveInvitation action is called and shows an alert box, sets up a responseMessage property, and finally deletes the content of emailAddress.

However, I got an error like this

Build error

library-app/controllers/index.js (in /Users/Cy/Desktop/ember/library-app/tmp/babel-input_base_path-oMvwkQCG.tmp/0)

The Broccoli Plugin: [Babel] failed with:
SyntaxError: library-app/controllers/index.js: Unexpected token (9:1)
    isDisabled: Ember.computed.not('isValid')

    actions: {
        saveInvitation() {
            alert(`Saving of the following email address is in progress: ${this.get('emailAddress')}`);
            this.set('responseMessage', `Thank you! We've just saved your email address: ${this.get('emailAddress')}`);

Anybody could let me know what causes the error and how to fix it? Thanks




Aucun commentaire:

Enregistrer un commentaire