1
我正在使用Intellij編寫angular2 dart應用程序。使用飛鏢爲angular2組件定義提供者
我創建了一個名爲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被complaning關於提供商陣列與所述錯誤消息arguments of constant creation must be constant expressions
我使用以下代碼中定義的驗證服務。
我是新來的飛鏢......但如果組件配置需要consts,我該如何提供在那裏使用的類?
感謝