I'm trying to create a service in Angular, but my compiler (Gulp) seems to be having problems with the variable that I define in the beginning. The exact error is Module build failed: SyntaxError: C:/*PATH*/src/app/components/demo.service.js: Unexpected token (8:8)
, and the code it's pointing at is this: var demos = [new Demo("Example Demo", "<b>Example Demo</b>")];
with it pointing specifically at the "d" in the variable name. For context, here's the whole file:
import { Demo } from './interfaces/demo';
export class DemosService {
constructor() {
'ngInject';
}
var demos = [new Demo("Example Demo", "<b>Example Demo</b>")];
addDemo(name, html) {
this.demos.push(new Demo(name, html));
}
removeDemo(name) {
this.demos.splice(this.demos.indexOf(name), 1);
}
updateDemo(oldName, newName, html) {
this.demos[this.demos.indexOf(oldName)].setName(newName);
this.demos[this.demos.indexOf(oldName)].setHtml(html);
}
getDemoInfo(name) {
return [this.demos[this.demos.indexOf(name)].getName(), this.demos[this.demos.indexOf(name)].getHtml()];
}
getDemos() {
return this.demos;
}
}
I'm sure this is a really stupid question and that the solution is really easy, but I just can't seem to find it. Thank you all in advance!