私はちょうどそれを古いやり方を行い、ロケット科学なしでそれを解決しました。 RC4にタイピングを正しく解決するのに問題があるようです。しかし、私はソフトウェア開発者であり、すべての角関連の "RC stuff"が前回より多く変更されているので、RCでこれを解決するのは難しいので、少し古い学校にすることにしました:
declare var $: any; // <-- yep, that's it
declare var FlipClock: any; // <-- same here
@Component({
selector: 'my-component',
moduleId: module.id,
templateUrl: './template.html',
styleUrls: ['./styles.css']
})
export class MyComponent implements AfterViewInit {
@ViewChild('flipclock') flipClock: ElementRef;
errors: any;
constructor() {
}
ngAfterViewInit() {
$(this.flipClock.nativeElement).FlipClock({ // <-- we must make sure that
clockFace: 'TwentyFourHourClock' // at runtime $ and FlipClock
// exists
});
}
}
は、実行時にjQueryとパタパタ時計を提供するために、私たちは私たちのindex.html
でスクリプトを追加する必要があります。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>My ng2-rc4 app</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="vendor/flipclock/compiled/flipclock.css">
<link rel="stylesheet" href="app/main.css">
</head>
<body>
<my-app>Loading ...</my-app>
<script src="/vendor/jquery/dist/jquery.min.js"></script>
<script src="/vendor/flipclock/compiled/flipclock.min.js"></script>
</body>
</html>
これは、あなたの質問に関連していないが、あなたは、あなたがAngular2でのjQueryを必要と確信していますか?一緒にうまく動作しません。 –
はい、jQueryに依存する外部依存関係が1つ必要です。それは悪いですが、ng2大学では現在私が使用できるプロジェクトはあまりありません。しかし、ここに言及してくれてありがとう。 –