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:“&” –