I've been attempting to update my angular 2 alpha 35 app to alpha 44. At
Eric Martinez' suggestion, I startred with this Hello World (which uses
alpha 42):
https://github.com/pkozlowski-opensource/ng2-play/blob/master/index.html
That worked fine with alpha 44, so I tried adding files from my legacy
project I was able to fix various errors, but I still get 2 errors
*Uncaught SyntaxError: Unexpected reserved word*
on this line:
import { Component, View, bootstrap, bind } from 'angular2/angular2';
and
*http://localhost:9000/app.js did not call System.register or AMD define*
* Error loading http://localhost:9000/app.js*
I had copied the .ts and .js files from the other folder to this one. I'm
not sure if this has something to do with a module format, es6 issue, or
something like that. es6, shims, transpiling, etc. are all fairly new to me.
-Vern
Entire source code for app.ts for those curious:
import { Component, View, bootstrap, bind } from 'angular2/angular2';
import { RouteConfig, RouterLink, RouterOutlet, routerInjectables,
LocationStrategy, HashLocationStrategy } from 'angular2/router';
// Pages
import { Home } from "./pages/home"
import { UserPreferences } from "./pages/prefs"
import { Study } from "./pages/study" // We don't have to specify the
.js extension
import { Report } from "./pages/report"
// Directives
import { Multiselect } from "./directives/multiselect"
import { Polarmap } from "./directives/polarmap"
@Component({ selector: 'csreport' }) // This component is injected
into <csreport></csreport> tags in HTML
@View({
templateUrl: 'navbar.html',
directives: [RouterLink, RouterOutlet]
}) // View: defines HTML that represents the component
@RouteConfig([
{ path: '/', redirectTo: '/home' },
{ path: '/study/:id', as: 'study', component: Study },
{ path: '/report', as: 'report', component: Report },
{ path: '/home', as: 'home', component: Home },
{ path: '/prefs', as: 'prefs', component: UserPreferences }
])
class CSReportMain {
name: string;
studyid: number;
constructor()
{
if (!window.myDialogs)
window.myDialogs = {};
this.studyid = 999;
}
test() {
return 80;
}
}
var universalInjectables = [
routerInjectables,
bind(LocationStrategy).toClass(HashLocationStrategy)
];
//bootstrap(CSReportMain, [routerInjectables, httpInjectables,
formInjectables]);
bootstrap(CSReportMain, [universalInjectables]) // bootstrap() returns a
promise we can use to get success/failure info
.then(app => {
console.log("Bootstrap of CSReportMain Successful");
}, err => {
console.error("Bootstrap of CSReportMain failed. Error: ", err);
});
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.