0
我跟着这个doc,但图像不显示在用户界面上。我需要使用复选框,我读到它应该在图像的帮助下完成。所以我的复选框图像没有出现。我在哪里做错了?图片无法加载Angular 2
import {Component, EventEmitter} from '@angular/core';
import {NS_ROUTER_DIRECTIVES} from 'nativescript-angular/router';
import {APP_ROUTER_PROVIDERS} from "../app.routes"
import ImageModule = require("ui/image");
var ImageSourceModule = require("image-source");
var image = new ImageModule.Image();
image.imageSource = ImageSourceModule.fromResource("checkbox_checked");
//image.imageSource = ImageSourceModule.fromResource("checkbox_unchecked");
@Component({
selector: "checkbox",
properties: ['checked : checked'],
events: ['tap'],
template: `
<StackLayout backgroundColor="#b3d9ff" width="300" height="550">
<Label style="font-size : 20px" text="Choose contacts to sync"></Label>
<Image
[src]="checked ? 'res://checkbox_checked' : 'res://checkbox_unchecked'"
class="checkbox"
(tap)="onTap()"
dock="left">
</Image>
</StackLayout> `
})
export class SyncComponent{
public tap: EventEmitter<boolean> = new EventEmitter<boolean>();
public checked: boolean = false;
constructor() { }
public onTap(): void {
this.tap.next(this.checked);
}
}
'属性:'应该是'输入:'和'事件:'应该是'输出:'。 “属性”和“事件”自很长一段时间以来都被弃用了。 –
非常感谢。我对角度很陌生。 我已经取代了他们,但仍然没有改变。有什么我仍然失踪? – kenkulan
我没有想到这会解决你的问题。我不知道NativeScript。 'res:// ...'URL对我来说很奇怪,但可能是NS特有的 –