Notify AngularJS controller about events from the outside

New to Angular, so we apologize if the question is stupid.

So, I’m making an application, and one part of it is outside the Angular “so to speak” area, and this part is responsible for receiving incoming messages (xmpp)

And then there is the Angular controller, which should receive notifications about incoming messages. What I did is an ugly job, but it works:

view.html:

<button ng-click="refreshLayout()" id="refreshLayoutButton" style="display:none"></button>

controllers.js:

.controller('chatCtrl', function($scope) {
     $scope.refreshLayout = function() { ... }
})

outside.js:

if(incomingMessage) {
     $("#refreshLayoutButton").click();
     // append the message to view.html
}

Is there anyway to exclude jQuery? I want to send a message from external.js to chatCtrl and then send it to view.html

OR

just report this event so that it can call $ scope.refreshLayout (techincally I can add incoming messages directly to view.html using jQuery without Angular, but the first option is even more preferable)

+3
2

, .

External.js $broadcast, .

.js , $on.

: http://jsfiddle.net/simpulton/XqDxG/

+2

... view.html jQuery Angular

Angualrjs. ( jQuery ). Angular jQuery-lite edition

Angular...

, " AngularJS" , jQuery? ,

, , outside.js: , .

, , , $eval. , $eval: Demo Fiddle

( ) . , , Google maps .

+1

All Articles