我有這樣AngularJS動態表單
$scope.ProdLinkFormData = {};
$scope.ProdLinkFormData.link = [{
link: null,
price: null,
priceType: null,
category: null
}, {
link: null,
price: null,
priceType: null,
category: null
}];
$scope.addLinkItem = function() {
$scope.ProdLinkFormData.link.push({
link: null,
price: null,
priceType: null,
category: null
});
};
$scope.removeLinkItem = function(linkItem) {
//console.log(subscriber);
$scope.ProdLinkFormData.link.pop(linkItem);
};
我的看法動態形式的函數包含這樣的
<div id="web" ng-repeat="linkItem in ProdLinkFormData.link">
<div class="row col-xs-12">
<div class="col-xs-6">
<div class="form-group">
<label class="col-md-6 control-label">*Category: </label>
<select class="pull-left" id="prodLinkCategory" name="prodLinkCategory" ng-required="true" ng-model="prodLinkNew[$index].category" required/>
<option ng-repeat="item in scpProdLinkCat" value="{{item.prodlink_category_value}}" ng-selected="prodLinkNew[$index].category==item.prodlink_category_value">{{item.prodlink_category_name}}</option>
</select>
</div>
<div class="form-group">
<label class="col-md-6 control-label">Price (optional): </label>
<div class="input-group">
<div class="input-group-btn">
<select class="btn btn-primary dropdown-toggle dropdown-toggle-split" name="price" id="price" ng-model="prodLinkNew[$index].price_type">
<option ng-repeat="item in scpPriceType" value="{{item.pricetype_name}}">{{item.pricetype_name}}</option>
</select>
</div>
<input type="number" class="col-md-1 input-group inline form-control" name="price" id="price" ng-model="prodLinkNew[$index].price" ng-pattern="/^[0-9]+$/"/ng-value="prodLinkNew[$index].price">
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-md-6 control-label">*Product Link EC: </label>
<div class="col-md-6">
<input type="text" class="form-control" name="prodEC" ng-required="true" id="prodEC" ng-model="prodLinkNew[$index].Productlink_EC" required/>
</div>
</div>
</div>
</div>
它相應地顯示,但我的問題是,如果我有兩個數據數據庫中,只有一個數據將在頁面加載時顯示在表單上,第二個數據只有在我添加另一個數據後纔會顯示。我怎樣才能同時顯示兩個數據?
顯示您的視圖和控制器完全定義理想插入正在運行的腳本。 – shaunhusain
@shaunhusain編輯我的問題,添加我的視圖 – bleykFaust