博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ionic2 textarea Automatically grows
阅读量:7090 次
发布时间:2019-06-28

本文共 1265 字,大约阅读时间需要 4 分钟。

Installation

npm install angular2-elastic

Quick Start

  1. Import the ElasticModule.
  2. Add the directive fz-elastic to your textarea or ion-textarea.
  3. Watch as your textareas automatically grow and shrink depending on their content.

Angular 2

1. Import the ElasticModule:

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule }   from '@angular/forms';
import { ElasticModule } from 'angular2-elastic';
 
import { AppComponent }  from './app.component';
 
@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    ElasticModule
  ],
  declarations: [
    AppComponent
  ],
  bootstrap: [ AppComponent ]
})
export class AppModule {}
 

2. Use the directive in your component HTML:

import { Component } from '@angular/core';
 
@Component({
  selector: 'my-app',
  template: `<textarea fz-elastic></textarea>`
})
export class AppComponent {};
 

That's it! Your textarea will now grow and shrink as you type.

The textarea will also respond to changes from any one or two way bindings that are setup, e.g. with [(ngModel)].

 

Ionic 2

  1. Import the module as above.
  2. Use the directive on an ion-textarea instead:
<ion-textarea fz-elastic></ion-textarea>
 
https://github.com/stevepapa/angular2-autosize

转载于:https://www.cnblogs.com/brucejchen/p/7483774.html

你可能感兴趣的文章
python下RSA加密解密以及跨平台问题
查看>>
详解Java Spring各种依赖注入注解的区别
查看>>
android 区分wifi是5G还是2.4G(转)
查看>>
多个构造器参数使用构建器
查看>>
模板方法模式(Template Method)
查看>>
创建预编译头 Debug 正常 Release Link Error:预编译头已存在,使用第一个 PCH
查看>>
asp.net上传文件夹权限配置以及权限配置的分析
查看>>
IPC's epoch 6 is less than the last promised epoch 7
查看>>
C语言 · 寂寞的数
查看>>
android Menu 笔记
查看>>
Apache2.2和Apache2.4中httpd.conf配置文件 权限的异同
查看>>
error:Flash Download failed-“Cortex-M3”,“Programming Algorithm”【转】
查看>>
小tips:JS之break,continue和return这三个语句的用法
查看>>
【Java】Java_09 类型转换
查看>>
AndroidStudio gradle配置
查看>>
poj3067 Japan(树状数组)
查看>>
[java面试]关于多态性的理解
查看>>
常见的MIME类型
查看>>
Leetcode_Wildcard Matching
查看>>
docker 私有仓库简易搭建
查看>>