我需要在“nextBtn”中添加 ng-disabled 指令,因为该按钮需要保持禁用状态,直到条件为真。可能吗?ng-if 或 ng-class 也是如此。我不能在模板中使用它们,我不知道为什么..这是我的情况:
function elementTourTemplate(content, isEnd){
return '<div class=\"row custom-color\">' +
'<div id=\"pop-over-text\" class=\"col-md-12\">' +
content +
'</div>' +
'</div>' +
'<hr>' +
+ $scope.rFunction() +
'<div class=\"row\">' +
'<div class=\"col-md-8 qt-tmpl-footer-modal\">' +
'<a class=\"skipBtn pull-left qt-margin-min\" type=\"button\">Skip</a>' +
'<button id=\"prevBtn\" class=\"prevBtn uk-button uk-button-danger qt-margin-min\" type=\"button\">' +
'Back</button>' +
'<button ng-disabled=\"$scope.rFunction() == false\" id=\"nextBtn\" class=\"nextBtn uk-button uk-button-success\" type=\"button\">' +
'Next <i class=\"glyphicon glyphicon-chevron-right\">'+
'</button>'+
'</div>' +
'</div>'
}
$scope.config=[
{
type: "element",
selector: "#left-tree-folders",
heading: "Test one",
text: "Click here to go to the next step",
placement: "right",
scroll: true,
elementTemplate: elementTourTemplate
}, ....
好吧,正如你所看到的,我有一个自定义模板,我可以在其中显示我需要的值:$scope.rFunction()
当我尝试标记此函数时,该函数在模板的任何元素之外返回一个布尔值,它正在工作。但是,如果我尝试将它放在像 ng-disabled 或 ng-if not 这样的指令上。任何想法?谢谢
编辑:正如我所建议的那样,我尝试使用 $compile 但现在我有了这个
angular.js:12793 TypeError: scope.$new is not a function
at compositeLinkFn (http://10.100.0.158:8280/docmenu/vendor/angular-1.5.0-beta.2/angular.js:7836:34)
at compositeLinkFn (http://10.100.0.158:8280/docmenu/vendor/angular-1.5.0-beta.2/angular.js:7859:13)
at Object.publicLinkFn [as elementTemplate] (http://10.100.0.158:8280/docmenu/vendor/angular-1.5.0-beta.2/angular.js:7736:30)
at Object.Element (http://10.100.0.158:8280/docmenu/vendor/ng-joyride/ng-joyride.js:37:47)
at http://10.100.0.158:8280/docmenu/vendor/ng-joyride/ng-joyride.js:555:40
at Array.map (native)
at initializeJoyride (http://10.100.0.158:8280/docmenu/vendor/ng-joyride/ng-joyride.js:545:44)
at Object.fn (http://10.100.0.158:8280/docmenu/vendor/ng-joyride/ng-joyride.js:498:25)
at Scope.$digest (http://10.100.0.158:8280/docmenu/vendor/angular-1.5.0-beta.2/angular.js:16165:29)
at Scope.$apply (http://10.100.0.158:8280/docmenu/vendor/angular-1.5.0-beta.2/angular.js:16429:24)