我正在使用 Intellij 编写一个 angular2 dart 应用程序。
我创建了一个名为的提供程序Auth
,它应该被注入到应用程序组件中。
我使用以下代码定义了 Auth 服务:
import 'package:angular2/core.dart';
import 'package:auth0_lock/auth0_lock.dart';
import './config.dart';
@Injectable()
class Auth {
Auth0Lock lock;
Auth() {
this.lock = new Auth0Lock(configObj.auth0.apiKey, configObj.auth0.domain);
}
updateProfileName(data) {
var profile = data['profile'] != null ? data['profile'] : data;
print(profile['name']);
}
login() {
this.lock.show(popupMode: true, options: {'authParams': {'scope': 'openid profile'}}).then(this.updateProfileName);
}
}
以及使用以下代码的应用程序组件:
import 'package:angular2/core.dart';
import 'package:angular2/router.dart';
import 'welcome_component.dart';
import 'auth_service.dart';
@Component(
selector: 'my-app',
templateUrl: '/www/my-app.html',
providers: [Auth]
)
@RouteConfig(const [
const Route(path: '/welcome', component: WelcomeComponent, name: 'welcome')
])
class AppComponent {
Auth auth;
AppComponent(Auth auth) {
this.auth=auth;
}
}
现在 intellij 正在用错误消息抱怨提供者数组arguments of constant creation must be constant expressions
。
我是 dart 的新手......但是如果组件配置需要 consts,我如何提供要在那里使用的类?
谢谢