I hope someone can point me in the right direction. We have an existing 
file upload solution which I need to add a feature to, I though I would 
ease in some more Angular into our application to do this as cleanly as 
possible. Once a file has uploaded a li representing the uploaded file's 
state will be added to the dom using jQuery, say something like.

<li id="asset1" 'ng-controller"="assetsPollerController as poller'>
    <span class="status {{status}} 
ng-init=>"id=1;state='queued';pollVideoAsset(1)">{{state}}</span
</li>

If this was already in the dom at the time that the angular code below was 
run, all is well.

adminApp = angular.module('adminApp', [])
adminApp.controller 'assetsPollerController', ($scope, $http) ->
  $scope.pollVideoAsset = ->
    if $scope.state == 'queued' || $scope.state == 'awaiting_file'
      $http.get('/api/v1/assets/' + $scope.id)
        .success (response) ->
          if response.video.state == 'queued'
            $timeout($scope.pollVideoAsset, 5000)
          else
            $.log(response.video.state)

However, how would I go about triggering the controller to take note of the 
newly included element in the page. Is there a way to re-run the controller 
for the page so that it picks anything new?

Many thanks for any thoughts and comments that might lead me in the right 
direction.

RobL

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to