我有以下服务,它应该是一个角度1服务;
import * as angular from 'angular';
module Services {
export class testService {
public getMessage(): string {
return "Message";
}
}
}
export = Services;
var app = angular.module('services', []);
app.service("testService");
另外,我有以下angular2代码,我想从以下angular2代码调用testService:
import {Component, Inject, Injectable
} from '@angular/core';
import {UpgradeAdapter} from '@angular/upgrade'
import {DataStore} from '../../src/datastore';
import {testService} from '../../src/testService'
import * as angular from 'angular'
let upgradeAdapter = new UpgradeAdapter();
upgradeAdapter.upgradeNg1Provider('testService', { asToken: testService });
@Component({
templateUrl: 'build/pages/hello-ionic/hello-ionic.html',
})
@Injectable()
export class HelloIonicPage {
message: string;
constructor(testService1: testService) {
this.message = testService1.getMessage();
}
}
问题是当我运行上面的代码时,它告诉我testService
没有提供者,所以我在这里缺少什么?