Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在组件中包含xml';你的观点是什么? 说明:_Xml_Angular_Nativescript_Angular2 Nativescript - Fatal编程技术网

如何在组件中包含xml';你的观点是什么? 说明:

如何在组件中包含xml';你的观点是什么? 说明:,xml,angular,nativescript,angular2-nativescript,Xml,Angular,Nativescript,Angular2 Nativescript,我正在浏览NativeScript的github-like上的文档和一些项目,它讨论如何实现 我很好奇地注意到Drawer组件的XML被复制并放在每个页面视图的顶部 例如在home.component.html中 <!-- RadSideDrawer is a UI component part of the Progress NativeScript UI set of components. Learn more about the RadSideDrawer UI component

我正在浏览NativeScript的github-like上的文档和一些项目,它讨论如何实现

我很好奇地注意到Drawer组件的XML被复制并放在每个页面视图的顶部

例如在home.component.html中

<!--
RadSideDrawer is a UI component part of the Progress NativeScript UI set of components.
Learn more about the RadSideDrawer UI component and how it can be customized in this documentation article:
http://docs.telerik.com/devtools/nativescript-ui/Controls/Angular/SideDrawer/getting-started
The RadSideDrawer component is designed to be used as a root element and
it shouldn't have any other siblings other than the <ActionBar> component.
-->
<RadSideDrawer #drawer showOverNavigation="true" [drawerTransition]="sideDrawerTransition">
    <!--
    Use the tkDrawerContent directive to display the content of the app drawer on this page.
    -->
    <StackLayout tkDrawerContent>
        <MyDrawer [selectedPage]="'Home'"></MyDrawer>
    </StackLayout>

    <!--
    Use the tkMainContent directive to display the content of the page when you have an app drawer.
    -->
    <StackLayout class="page appPage homePage" tkMainContent>
    </StackLayout>
</RadSideDrawer>

这段代码将被复制并放置在每个其他页面视图的顶部。这是很多冗余代码

问题: 为什么他们要在每一页的抽屉视图中复制?有没有一种方法可以包含视图


angular方法只需在html文件中写入抽屉的选择器,但这不起作用,因为NativeScript视图是XML。

如果使用angular,则应该可以。为抽屉内容创建一个组件,然后设置选择器并将其添加到抽屉视图中


将它添加到声明中的app.module.ts文件中,然后在主视图中使用

但它没有,这是我在谈到添加选择器时指出的。明天我会再次运行它,看看我是否忘记了什么,并将错误添加到我的帖子中。谢谢
@Component({
    selector: "my-drawer-content",
    moduleId: module.id,
    templateUrl: "./drawercontent.component.html",
    styleUrls: ["./drawercontent.component.css"],
})