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);
}
}
そして、次のコードを使用する app コンポーネント:
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 は、providers 配列についてエラー メッセージを表示していますarguments of constant creation must be constant expressions
。
私はダーツを初めて使用します...しかし、コンポーネント構成にconstが必要な場合、そこで使用されるクラスをどのように提供できますか?
ありがとう