0.10.5 textAreaList

by vaiism

HTML

<script src="http://code.angularjs.org/angular-0.10.5.min.js" ng:autobind></script>
<script>
function AuditController() {
    this.parameters = ["John","Fred"];
}

angular.inputType('textAreaList', function(){
    this.$parseModel = function(){
        if (this.$modelValue) {
            this.$viewValue = this.$modelValue.join('\n');
        }
    };
    this.$parseView = function(){
        if (this.$viewValue.length != 0) {
            this.$modelValue = this.$viewValue.split('\n');
        } else {
            this.$modelValue = [];
        }
    };
});
</script>

<div ng:controller="AuditController">
    <form name="testForm">
        <textarea type="textAreaList" name="parameters" ng:model="parameters" style="resize: none;height:100px;">
        </textarea>
    </form>
    <hr/>
    Parameters:
    <pre>{{parameters}}</pre> <br/>
</div>

CSS

body {font-family:sans-serif;font-size:12pt;padding:10px; }
.error { color: red; }
input, select {
    margin: 4px;
}
input.ng-invalid, select.ng-invalid, textarea.ng-invalid, input.formElement.ng-invalid {
    border: solid 1pt red;
}
textarea { padding: 4px; }
tt {font-size: 10pt;}
#output {background-color: #efefef;padding:5px;border:solid 1pt #ddd;}