NativeScript浮动提示

Oma*_*sam 1 android nativescript android-textinputlayout angular2-nativescript

我正在使用nativescript创建一个表单,我希望我的字段有像TextInputLayout一样的浮动提示,我发现这个插件nativescript-textinputlayout技术上完全符合我的要求,但问题是我使用我的应用程序使用了角度2,并且我似乎无法弄清楚如何使用角度为2的插件.有人可以帮忙吗?除了使用插件实现浮动提示之外,我还对其他解决方案持开放态度

Dim*_*sev 5

nativescript-textinputlayout是一个"vanilla"NativeScript组件.要将其与Angular一起使用,您需要使用元素注册表API将其注册为Angular模板的有效标记.

例:

我-component.component.ts

import { registerElement } from "nativescript-angular/element-registry";

registerElement("TextInputLayout", () => require("nativescript-textinputlayout").TextInputLayout);

@Component({
   selector: "my-component",
   moduleId: module.id,
   templateUrl: "./my-component.component.html"
})
export class MyComponent {}
Run Code Online (Sandbox Code Playgroud)

我-component.component.html

<StackLayout>
   <TextInputLayout hint="my hint" hintAnimationEnabled="true">
      <TextField text="my content"></TextField>
   </TextInputLayout>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)