我使用typescript构建一个角度2应用程序,我尝试创建新的组件调用sidekik.component.ts并导入到这样的app.component.ts.
app.component.ts
import {Component} from 'angular2/core';
import {SideKikComponent} from './classes/sidekik.component';
interface Hero {
id: number;
name: string;
}
@Component({
selector: 'my-app',
directives:[
SideKikComponent,
],
templateUrl:'app/views/heros.html',
styleUrls: ['app/css/site.css']
})
export class AppComponent {
public title = 'Tour of Heroes';
public heroes =HEROS;
public selectedHero: Hero;
onSelect(hero: Hero) {
this.selectedHero = hero;
}
}
var HEROS: Hero[] =[
{"id":1,"name":"SuperMan"},
{"id":2,"name":"Captain America"},
{"id":3,"name":"Thor"},
{"id":4,"name":"Iorn Man"},
{"id":5,"name":"Ant Man"}
];
Run Code Online (Sandbox Code Playgroud)
sidekik.component.ts
import {Component, View} from 'angular2/core';
@Component({
selector:'sidekik',
events:['hit'],
properties:['define'],
template: `
<sidekik (click) = …Run Code Online (Sandbox Code Playgroud) 我使用角度cli创建应用程序并使用后端代理来处理后端并使用聚合物(vaadin)它正常工作,直到我更新到角度cli 1.0.0-beta.22它给出错误
Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.
Run Code Online (Sandbox Code Playgroud)
proxy.conf.json
{
"/api": {
"target": "http://127.0.0.1:3000",
"secure": false
}
}
Run Code Online (Sandbox Code Playgroud)
主polymer.ts
document.addEventListener('WebComponentsReady', () => {
require('./main.ts');
});
Run Code Online (Sandbox Code Playgroud)
main.ts
import './polyfills.ts';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/';
if (environment.production) {
enableProdMode();
}
// platformBrowserDynamic().bootstrapModule(AppModule);
platformBrowserDynamic().bootstrapModule(AppModule);
Run Code Online (Sandbox Code Playgroud)
我怎么能纠正这个?
我在官方网站上有以下角度文档.但在文档测试中,部分已过时,无法使用当前的角度2 beta版本.我需要编写一个基本测试来检查if条件是否正常工作.我怎么能用角度2中的茉莉花做到这一点.
我正在使用angular2创建应用程序,我需要从雅虎天气获得天气.我尝试使用http get方法,但它给了我一个错误.
import {Component,OnInit,} from "angular2/core";
import {Http} from "angular2/http";
import 'rxjs/add/operator/map';
@Component({
templateUrl:'app/contact/contact.html',
})
export class ContactComponent{
constructor (private http: Http) {}
public url:string= "http://weather.yahooapis.com/forecastjson?w=2295424";
ngOnInit(url:string) {
return this.http.get(url).map(res => {
return res.json();
}).subscribe((response) => { console.log(response) });
}
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是
EXCEPTION:SyntaxError:JSON.parse:JSON数据第1行第1列的意外字符
谁能帮我这个?.