0
我在頁面上有4個選擇下拉列表。在每一個下面,我都希望動態HTML基於角度形式的選擇來生成。將模型傳遞給AngularJS中的指令
我有這個至今:
ruleSelect.js.erb
angular.module('productsApp')
.directive('ruleSelect', [
function() {
return {
restrict: 'E',
replace: false,
// require: 'ngModel',
scope: {
options: '=',
ruleBldr: '='
},
templateUrl: "<%= asset_path('shared/templates/ruleSelect.html') %>",
link: function(scope, element, attrs){
}
};
}]);
ruleSelect.html.slim
select.form-control ng-model="value"
option ng-repeat="field in options | fieldFilter:['templateOptions', 'label']" value="{{$index+1}}"
| {{field.templateOptions.label}}
form
formly-form fields="ruleBldr.form[value].fieldGroup"
但在範圍options
設置,但ruleBldr
是空的。
HTML頁面
.row
.col-md-offset-6.col-md-6 ng-repeat="obj in ruleB.formObjects"
label.control-label() {{obj.fieldGroup[0].template}}
rule-select options='obj.fieldGroup' ruleBldr="obj"
初始值,但ruleBldr具有正確的密鑰,但所有的值都爲空。 – mikeglaz
有一個非常困難的時間跟在確切的問題是什麼。創建一個複製這個 – charlietfl
的演示,在html中'ruleBldr =「obj」'應該是'rule-bldr =「obj」'。一個很好的竅門是'
'在視圖中查看範圍對象看起來像什麼 – charlietfl