数据模型是这样的:
"audio": {
"faultType": "string" //声音故障类型
},
"screen":{
"number": "string" //屏幕故障数量
"faultType": "string" //屏幕故障类型
}
前台对应的声音故障类型,屏幕故障数量,屏幕故障类型这三个输入项用ng-model要怎么绑定?
控制器里这么写可以吗?
$scope.data = {
lineNo:$scope.lineNo,
trainNo:$scope.trainNo,
createdAt:$scope.createdAt,
audio: {
faultType:$scope.fault,
},
screen:{
number:$scope.number,
faultType:$scope.faultType,
}
}
某草草2017-05-15 17:13:27
으아악
js에서는 이렇게 쓸 수 있습니다.
var data = [
"audio": {
"화면":{
으아악}];
json.parse(데이터);
PHP中文网2017-05-15 17:13:27
controller:
$scope.model={
"audio": {
"faultType": "type1" //声音故障类型
},
"screen":{
"number": 2 //屏幕故障数量
"faultType": "type2" //屏幕故障类型
}
}
HTML:
<p>声音故障类型:{{model.audio.faultType}}</p>
<input type='text' ng-model="model.audio.faultType">
<p>屏幕故障数量:{{model.screen.number}}</p>
<input type='number' ng-model="model.screen.number">
<p>屏幕故障类型:{{model.screen.faultType}}</p>
<input type='text' ng-model="model.screen.faultType">
이상