firebolt_ash
firebolt_ash

Reputation: 1324

Document query selector for a controller in Angular Js

I have a controller named like this :

<div ng-controller="MainController as main" class="containerWrap">

I tried this for selecting my controller for further functioning :-

var a = document.querySelector('[ng-controller=MainController as main]');
var b = angular.element(chatElement).scope();

It gives an error :-

Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document': '[ng-controller=MainController as main]' is not a valid selector.

I tried for just MainController as well :-

That gives :-

a=null
b=undefined

Can anyone help?

Upvotes: 0

Views: 2120

Answers (1)

CodePrimate
CodePrimate

Reputation: 6666

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

Upvotes: 2

Related Questions