我有一个名为这样的控制器:
<div ng-controller="MainController as main" class="containerWrap">
我尝试选择我的控制器以进一步运作: -
var a = document.querySelector('[ng-controller=MainController as main]');
var b = angular.element(chatElement).scope();
它出错: -
Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document': '[ng-controller=MainController as main]' is not a valid selector.
我也尝试过MainController: -
这给出了: -
a=null
b=undefined
有人可以帮忙吗?
答案 0 :(得分:0)
var a = document.querySelector('[ng-controller="MainController as main"]');