我想根據當前位置路徑去除導航欄。使用AngularJS去除DOM元素
這是我到目前爲止有:
angular.module('myModule')
.controller('MainController', function ($location, $document) {
if ($location.path().indexOf('resetpass') > -1) {
var navbar = angular.element($document.querySelector(".top-navbar"));
navbar.remove();
}
});
這種方法的控制檯說:
angular.js:14110 TypeError: $document.querySelector is not a function
at new <anonymous> (main.controller.js:6)
at Object.invoke (angular.js:4762)
at $controllerInit (angular.js:10518)
at nodeLinkFn (angular.js:9416)
at compositeLinkFn (angular.js:8757)
at compositeLinkFn (angular.js:8760)
at publicLinkFn (angular.js:8637)
at angular.js:1808
at Scope.$eval (angular.js:17913)
at Scope.$apply (angular.js:18013)
我在做什麼錯?
工程就像一個魅力!謝謝:) – Codehan25