角度指令未显示在ng-Switch中
Angular Directive not showing in ng-Switch
我有 4 个基于 var.type 显示的模板。我有 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"}
]
});
<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>
这不是一个有效的例子,但它应该足以说明希望能阐明这一重大挫折。
提前谢谢。
你有一个错别字,肯定会搞砸它:
"data-lod-report-variable-cfglookup"是你在HTML代码中写的指令名称,而JS代码中的指令名称是"lodReportVariableCgflookup"。(cfglookup vs cgflookup)
编辑:此外,我注意到您在您说不起作用的两个指令上都使用了相同的指令"lodReportVariableCgflookup"。
您可能还有其他问题,但我会从那个:)开始
相关文章:
- 如何在ng-reeat中使用ng-switch来编辑JSON API数据
- 使用angularjs ng Show/ng hide显示和隐藏不同的内容
- 我需要NG-IF/NG-SWITCH还是NG-SHOW&NG-HIDE
- $scope变量,ng隐藏/显示
- AngularJS ng repeat显示原型函数未定义
- 尝试使用 AngularJS ng-repeat 显示 JSON 数据不起作用
- 角度ng重复显示应用过滤器之前的数据
- 有角度的ng消息显示ng重复表单上的错误
- Ng只显示互动的更新
- ng show显示所有项目
- 使用ng Show显示/隐藏按钮
- 在 ng-switch 中使用 ng-transclude
- 如何在使用 ng-repeat 显示表数据时放置条件新行
- Bootstrap Switch 显示/隐藏表列 - 初始配置和值存储
- 如何在模板的 ng-switch 中使用指令的属性
- 嵌套的 ng 重复显示错误的$index
- 如何使用 ng-switch 切换显示带有 AngularJS 的嵌套表
- 角度指令未显示在ng-Switch中
- 使用ng-if/ng-show/ng-switch的Angular条件显示会简要地显示这两个元素
- AngularJS只显示一个ng-switch