When i import 2 components within directives:[]
the second component comes with this error File stores.component.xml does not exists
.
What Works
When there is only 1 component in directives: []
or use template instead of templateUrl
app.component.ts
import { Component, OnInit } from "@angular/core";
import { Page } from 'ui/page';
import { ChatsComponent } from './chats/chats.component';
import { StoresComponent } from './stores/stores.component';
@Component({
selector: "my-app",
templateUrl: 'app.component.xml',
directives:[ ChatsComponent, StoresComponent ]
})
app.component.xml
<TabView>
<StackLayout *tabItem="{title: 'Chats'}">
<chats></chats>
</StackLayout>
<StackLayout *tabItem="{title: 'Store'}">
<stores></stores>
</StackLayout>
</TabView>
答案 0 :(得分:1)
nativescript删除了角度module.id
,因此templateUrl
需要templateUrl: 'app.component.xml',
到templateUrl: '../app/YOUR_COMPONENT_DIRECTORY/NAME.component.xml'
答案 1 :(得分:1)
在nativescript 2中,使用ng2,'templateUrl'
文件的扩展名实际上是'.html'
而不是'.xml'