Properties 具有属性的自定义组件
我想知道如何在离子3中创建具有某些属性的我们自己的组件。离子按钮的“完整”属性就是一个例子。我想做的是呈现我自己的组件,它看起来像这样Properties 具有属性的自定义组件,properties,ionic3,Properties,Ionic3,我想知道如何在离子3中创建具有某些属性的我们自己的组件。离子按钮的“完整”属性就是一个例子。我想做的是呈现我自己的组件,它看起来像这样 <my-component my-property></my-component> 我强烈推荐angular.io网站上的任何基础教程 你想要的是一个很基础的角度,离子是杠杆 请看这里,我为您构建了一个简单的示例: 在ts文件中定义组件: import { Component, Input } from '@angular/core'
<my-component my-property></my-component>
我强烈推荐angular.io网站上的任何基础教程 你想要的是一个很基础的角度,离子是杠杆 请看这里,我为您构建了一个简单的示例: 在ts文件中定义组件:
import { Component, Input } from '@angular/core';
@Component({
selector: 'my-component',
template: `<div>{{ myProperty }}</div>`
})
export class MyComponent {
@Input('myProperty') myProperty: string;
constructor() {
}
}
谢谢你的代码。它很有效,正是我所需要的
<ion-content padding>
<h2>Welcome to Ionic!</h2>
<p>
This starter project comes with simple tabs-based layout for apps
that are going to primarily use a Tabbed UI.
</p>
<p>
Take a look at the <code>pages/</code> directory to add or change tabs,
update any existing page or create new pages.
</p>
<my-component [myProperty]="'I am a custom component'"></my-component>
</ion-content>