2015-02-12 68 views
-1

我有一個名爲像這樣的控制器:文檔查詢選擇

<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 

誰能幫助?

+1

圍繞「MainController as main」添加引號。 – 2015-02-12 09:24:48

+0

謝謝。早些時候,我沒有主要的實例 – 2015-02-12 09:31:10

回答

0
var a = document.querySelector('[ng-controller="MainController as main"]');