我根据var.type显示了4个模板。我有2/4正确显示,但由于某些原因,其中2个没有呈现任何东西。在HTML中我看到开关被正确激活,但指令没有按预期放入。
angular.module('lodgicalWebApp');
angular.module('lodgicalWebApp')
.directive('lodReportVariableCgflookup', function () {
return {
template: '{{var.name}}<label for="repeatSelect"> {{var.name}} </label> \
<select name="repeatSelect" ng-model="Vars[var.name]" id="repeatSelect" ng-model="data.repeatSelect"> \
<option ng-repeat="option in var.possibleVals" value="{{option.id}}">{{option.name}}</option> \
</select>',
restrict: 'EA'
};
});
angular.module('lodgicalWebApp')
.directive('lodReportVariableBoolean', function () {
return {
template: '{{var.name}}<input ng-model="Vars[var.name]" type="checkbox" ng-true="{{var.value}}">',
restrict: 'EA',
};
});
angular.module('lodgicalWebApp')
.controller('ReportsCtrl', function ($scope, $routeParams, LodgicalReportService, Report) {
$scope.selectedReport.variables = [
{name: "Start Date",possibleVals:[],type: "Date", value: "2016-01-18"},
{name: "Operator",possibleVals: [{id:1,name:"test"},{id:2,name:"thanksStackOverflow"}], type: "CfgLookup"},
{name: "Include Security Deposits", type: "Boolean", value: "False"}
]
});
&#13;
<div ng-repeat="var in selectedReport.variables">
<div ng-switch="var.type">
<!-- CfgLookup not rendering -->
<div ng-switch-when="CfgLookup" data-lod-report-variable-cfglookup ></div>
<div ng-switch-when="Boolean" data-lod-report-variable-boolean></div>
<div ng-switch-when="Date" data-lod-report-variable-date ></div>
<div ng-switch-when="CfgLookup-Multi" data-lod-report-variable-cfglookup></div>
</div>
</div>
&#13;
这不是一个有效的例子,但它应该足以说明这一重大挫折感。
提前致谢。
答案 0 :(得分:2)
你有一个错字,肯定会弄乱它:
&#34;数据LOD报告-可变cfglookup&#34;您在HTML代码中编写的指令名称,而JS代码中的指令名称是&#34; lodReportVariableCgflookup&#34;。 (cfglookup vs cgflookup)
编辑:此外,我注意到你使用了相同的指令&#34; lodReportVariableCgflookup&#34;在你说的两个指令都不起作用。
你可能还有另一个问题,但我从那个问题开始:)