I've a HTML page which has some DOM configured with Angular. Now I'm building a chrome extension to modifying value in a text box. element.value= newValue
will not work as the text box is designed with Angular. After reading some resources, I came to know that I need to do the changes to the scope of the element. I tried doing this in the extension.
var eleScope = window.angular.element(document.querySelector('.textbox')).scope();
eleScope.$apply(function() {
eleScope.item.request.box = newValue;
});
This doesn't seem to work as intended. When I dug into the problem more deeply, I came to know that the angular in the scope of window was not getting the right scope.
I also tried to inject angular.js from my extension and using angular.element
directly which also doesn't seem to solve the problem.
Am I missing something. Appreciate your replies.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…