Honestly I'm fairly new to Angular so I might be missing something obvious. 
I've attached the controller to the <li> because I would expect to have 
potentially multiple file uploads each <li> being inserted into the dom as 
each file upload completes which could then tigger the poller. So to me 
each <li> is a separate instance of the controller. That may or may not be 
how I should approach the problem however. Perhaps a controller that 
handles the state of all of the uploads might be more efficient anyway.

On Friday, March 6, 2015 at 5:34:05 PM UTC, Mo Moadeli wrote:
>
> You could retrigger the angular $compiler but that is an awfully heavy 
> task fir such a simple thing.  My question is why do you have the 
> ng-controller definition in the added 'li' node in the first place?  Why 
> don't you add it to some parent dom node that is 'persistent'?  Something 
> like this:
>
> <parent-node 'ng-controller"="assetsPollerController as poller'> ....
>
> <li id="asset1">
>     <span class="status {{status}} 
> ng-init=>"id=1;state='queued';pollVideoAsset(1)">{{state}}</span
> </li>
>
> </parent-node>
>
> where 'parent-node'  is any HTML dom tag.
>
> On Friday, March 6, 2015 at 12:15:38 PM UTC-5, Rob Lacey wrote:
>>
>> 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