【发布时间】:2019-05-20 09:56:23
【问题描述】:
我使用 Angular v7 制作了一个简单的 Web 应用程序,我想将它迁移到 NativeScript 移动应用程序。
我按照https://docs.nativescript.org/angular/code-sharing/migrating-a-web-project#migrating-components 中的说明进行操作,但遇到了困难。
该应用程序正在我的 Android 手机中运行,但它不显示内容,因为我需要针对移动应用程序对其进行适当调整。它显示自动生成的作品。问题是我不知道如何正确调整代码,因为我找不到正确的文档。有什么帮助吗?
我在 app.component.html 中的代码:
<!--The content below is only a placeholder and can be replaced.-->
<div style="text-align:center">
<h1>
Welcome to {{ title }}!
</h1>
</div>
<weather-search></weather-search>
<weather-list></weather-list>
<router-outlet></router-outlet>
我在weather-search.component.html中的代码:
<section class="weather-search">
<form (ngSubmit)="onSubmit(f)" #f="ngForm">
<div class="test_up">
<label for="city" class="city">City</label>
<input name="location" type="text" id="city" ngModel required>
</div>
<div class="test_down">
<label for="countryCode" class="city">Country Code</label>
<input name="countryCode" type="text" id="code" ngModel required>
</div>
<button type="submit">Add City</button>
</form>
<button (click)="onClickLocationData(f)">Get geolocation</button>
<label for="latitude" class="map" *ngIf="latitude!=0">Latitude: {{latitude}} </label>
<label for="longitude" class="map" *ngIf="longitude!=0">Longitude: {{longitude}} </label>
<div id="map" class="mapLocation"></div>
</section>
我在weather-list.component.html中的代码:
<section class="weather-list">
<weather-item *ngFor="let weatherItem of weatherItems" [item]="weatherItem"></weather-item>
</section>
我在weather-item.component.html中的代码:
<article class="weather-element">
<div class="col-1">
<h3>{{ weatherItem.cityName }}</h3>
<p class="info">{{ weatherItem.description }}</p>
</div>
<div class="col-2">
<span class="temperature">{{ weatherItem.temperature }}°C</span>
</div>
</article>
【问题讨论】:
-
The problem is I do not know how I can do adjust properly the code=> 有什么可以帮到你的,让我知道?我最近参与了几个 {NS} 代码共享项目。 -
@Narendra 嗨!感谢您及时的回复。成功运行命令 ng add @nativescript/schematics 和 **ng g migrate-component --name= ** 为每个组件,如果我在我的移动设备上运行它,它可以工作,但它确实不显示适当的内容。现在我不应该调整我发布的每个文件的内容吗?如何?你能用我的代码举个例子吗?
-
@Narendra 嗨!你能告诉我如何在 weather-search.component.html 中调整我的表单吗?
-
@Narendra 嘿,你按照你说的在 GitHub 中创建了一个 repo 吗?
标签: android angular migration nativescript angular7