1
我想檢查指令中是否存在屬性,我不知道該怎麼做,任何人都可以幫忙嗎?這可能是簡單的,但我是新來的角檢查指令是否存在屬性
(function() {
'use strict';
angular.module('app').directive('home', home);
var strVar="";
strVar += "<home show-text=vm.text></home>"
function home() {
return {
restrict: 'E',
transclude: true,
template: strVar,
scope: {
showText: "="
},
controller: HomeController,
controllerAs: 'vm',
bindToController: true
};
};
HomeController.$inject = ['$scope','$rootScope', '$timeout','$sce'];
function HomeController($scope,$rootScope,$timeout,$sce) {
if(vm.showText == 「undefined」)
{
//Run some code
}
})();
那對我來說不工作 – user5277847
是檢查該指令中是否存在屬性? – user5277847
我改變了showText後,我得到了這個工作:「=」showText:「&」 –