©
本文档使用
php.cn手册 发布
将文本输入在分隔的字符串和字符串数组之间转换。分隔符可以使用一个固定字符串 (默认为逗号) 或正则表达式。
<input
[ng-list=""]>
...
</input>
参数 | 类型 | 详述 |
---|---|---|
ngList
(可选)
|
string | 用于分隔值的可选分隔符。 如果格式为 |
<script>
angular.module('listExample', [])
.controller('ExampleController', ['$scope', Function($scope) {
$scope.names = ['igor', 'misko', 'vojta'];
}]);</script><form name="myForm" ng-controller="ExampleController">
List: <input name="namesInput" ng-model="names" ng-list required>
<span class="error" ng-show="myForm.namesInput.$error.required">
Required!</span>
<br>
<tt>names = {{names}}</tt><br/>
<tt>myForm.namesInput.$valid = {{myForm.namesInput.$valid}}</tt><br/>
<tt>myForm.namesInput.$error = {{myForm.namesInput.$error}}</tt><br/>
<tt>myForm.$valid = {{myForm.$valid}}</tt><br/>
<tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>
</form>
var listInput = element(by.model('names'));var names = element(by.binding('{{names}}'));var valid = element(by.binding('myForm.namesInput.$valid'));var error = element(by.css('span.error'));
it('should initialize to model', Function() {
expect(names.getText()).toContain('["igor","misko","vojta"]');
expect(valid.getText()).toContain('true');
expect(error.getCssValue('display')).toBe('none');});
it('should be invalid if empty', Function() {
listInput.clear();
listInput.sendKeys('');
expect(names.getText()).toContain('');
expect(valid.getText()).toContain('false');
expect(error.getCssValue('display')).not.toBe('none'); });