这是我的视图,其中我有3个下拉菜单。我正在尝试在我的控制器中获取值,我正在获取' undefined'
<div class="row">
<div class="input-field col s12">
<select ng-model="newRecord.newBaseTemplate" id="newBaseTemplate">
<option value="" disabled selected>Choose Base Template</option>
<option>A</option>
<option>B</option>
<option>D</option>
</select>
<label>Choose your Base Template</label>
</div>
</div>
<div class="row">
<div class="input-field col s12 " >
<select ng-model="newRecord.newProcessElement">
<option value="" disabled selected>Choose Process Element</option>
<option>PE1</option>
<option>PE3</option>
<option>PE6</option>
</select>
<label>Choose Your Process Element</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<select ng-model="newRecord.newScreenName">
<option value="" disabled selected>Choose Screen Name</option>
<option>ACTION_BAR</option>
<option>DETAIL_GROUP</option>
<option>NORMAL_VIEW</option>
</select>
<label>Choose Your Screen Name</label>
</div>
</div>
在控制器中,我在addNew方法中获取值,在我的视图中添加新按钮时调用该方法:
$scope.newRecord = {
'newBaseTemplate' : 'A',
'newProcessElement' : 'PE6',
'newScreenName' : 'ACTION_BAR'
};
$scope.addNew = function(){
var id = $scope.records.length + 1;
id = 'record' + id;
console.log($scope.newRecord.newBaseTemplate);
console.log($scope.newRecord.newProcessElement);
console.log($scope.newRecord.newScreenName);
$scope.records.push({
id : id,
baseTemplate : $scope.newRecord.newBaseTemplate,
processElement : $scope.newRecord.newProcessElement,
screenName : $scope.newRecord.newScreenName
});
};
答案 0 :(得分:1)
试试这个,
<div class="row">
<div class="input-field col s12 topMargin" >
<select ng-model="d.newPE">
<option value="" disabled selected>Choose Process Element</option>
<option>PE1</option>
<option>PE3</option>
<option>PE6</option>
</select>
<label>Choose Your Process Element</label>
</div>
</div>
初始化在控制器中
$scope.d = {};
并获取
$scope.d.newPE
答案 1 :(得分:0)
请参阅以下示例。它完美运行:
aaii
答案 2 :(得分:0)
我不知道它是否优雅,但我可以使用以下方法解决类似情况:
def log_finish_time(log_prefix):
def h(f):
def g(*args):
ret = f(*args)
print('{}: {} completed on {}'.format(log_prefix, f, time.time()))
return ret
return g
return h
@log_finish_time('A')
def f1(x):
return x+1
然后你可以随意附加newBaseTemplate,例如:
var newBaseTemplate = angular.element(document.getElementById('newBaseTemplate')[0]).val();