2014-06-05 1 views

답변

3

AngularjS에서는 ng-model에 따라 값이 변경됩니다. 예를 들어
는 HTML은

<div ng-controller="MyCtrl" ng-init="text = 'Hello'"> 
    <ons-text-input 
     ng-model="text" 
     style="display: block; width: 100%" value="OK"> 
    </ons-text-input> 

    <div ng-click="setText('changed1');">Change 1!</div> 
    <div ng-click="setText('changed2');">Change 2!</div> 
    <div ng-click="setText('changed3');">Change 3!</div> 
</div> 

이며 JS 코드는 가변 텍스트 자체가 변경 모델 겨하는 경우, 입력 값이 자동으로 변경

app = angular.module('myApp', ['onsen.directives']); 

app.controller('MyCtrl', function($scope) { 
    $scope.setText = function(str) { 
     $scope.text = str; 
    };  
}); 

이다.

관련 문제