feature request: change events from ng-repeat, ng-switch, ng-options, directives with templateUrl #996
Comments
This is a great use case, and i think we should support it. However, I don't think that the event system is the way to do it, since it would have a negative impact on performance. I was toying with the idea of monkey patching the jQuery to get the desired behavior, but I have not gotten very far with it. I guess that for your use case it would be sufficient to know when the position of an item has changed. |
Hello Miško, However, this would still not solve the problem when using directives with a templateUrl (they could also load content that would lead to a refresh of the parent widget). This could be solved if directives with a templateUrl would call a service like $compile (or a more specialized version), which I could track using a $provide.decorator. For the jquery mobile plugin to work correctly, I would need the information when an item is created, destroyed and when the position changes. I already had a version that listens for DOM changes using monkey patching in jQuery (essentially Tobias |
I agree, we need the create, move, and delete information for animation, so On Tue, May 29, 2012 at 9:22 AM, Tobias Bosch <
|
any news on this one? or tigbro, did you find a viable workaround in the meantime? |
Hi, Tobias |
I need it as well. |
I really need this feature. |
Hi, I have a proposal for this this issues. Check solution for Use: App.Controller.Home = function($scope){
$scope.$on('after-ngRepeat', function(event, stringCollectionName){
console.log('fire after-ngRepeat!', event, stringCollectionName);
});
$scope.$on('before-ngRepeat', function(event, stringCollectionName){
console.log('fire repeatBefore!', event, stringCollectionName);
});
}; if have recommendation, please comment! |
What is the use case for these events? On 14 November 2012 19:12, Jimmy Collazos notifications@github.com wrote:
|
Pete in my case need bind scroll in list (ng-repeat): Template.html <div id="wrapper" class="offers scroller-wraper">
<div class="scroller">
<ul class="clearfix">
<li ng-repeat="offer in offers" ng-click="openOffer()">
<img ng-src="{{offer.icon_src}}" alt="{{offer.name}}"/><br/>
a
<span>{{offer.name}}</span><br/>
<a href="#/coupon/{{offer.id}}">
<b>{{offer.price}}</b>
</a>
</li>
</ul>
</div>
</div> In my controller trying that: App.Controller.Home = function($scope, $route, $routeParams, $location){
$scope.offers = Service.Coupon();
new iScroll(document.querySelector('#wrapper'), {
snap: true,
momentum: false,
hScrollbar: false
});
}; of course, not found; because dispatch iScroll before the parse ng-repeat now I use this cr*p ;( App.Controller.Home = function($scope, $route, $routeParams, $location){
$scope.offers = Service.Coupon();
$scope.setScroll = function(){
new iScroll(document.querySelector('#wrapper'), {
snap: true,
momentum: false,
hScrollbar: false
});
};
setTimeout($scope.setScroll, 200);
}; |
Well, my usecase is already stated above for the integration of jquery mobile and angular. |
+1 |
+1, this would be very helpful in the long run. Also @Acido69 this is another option that works without using timeout: $scope.$watch(document.querySelector('#wrapper'), function() {
$scope.setScroll();
}); |
Well, animations has arrived, but instead of being built on a generic mechanism to hook into templating changes, it's just been hard-coded into all the directives. Are we supposed to misuse the animation events to do stuff like this now, even though is has nothing to do with animation? |
@ibspoof good idea! |
As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months. Please try the newest versions of Angular ( Thanks! |
acido69 ..... please can u share ur application demo i am working on Template.html in which i am using the ng-repeat with iscroll but it is not working |
acido69 : if i dont use ng-repeat it is working fine with my demo app....... any clue regarding this thanks in advance |
<script src="jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="jquery.mobile-1.3.2.min.js" type="text/javascript"></script>
<script src="iscroll.js" type="text/javascript"></script>
<script src="jquery.mobile.iscrollview.js" type="text/javascript"></script>
<script src="listview.js" type="text/javascript"></script>
<script src="angular.min.js" type="text/javascript"></script>
/************************************************************************************************************************** function Todfunction TodoCtrl($scope)
} Note : This code is working in chrome but not in web-kit please help me !!!!! tried all possible options |
@core123 You can try this dirty/fast solution: <li ng-repeat="list in lists">
<h3>{{list.text}}</h3>
<p>{{list.done}} With Angular JS</p>
{{ updateScroll($last) }}
</li> . // in controller
var Scroller = new iScroll('wrapper');
$scope.lists = [{text:'', done:''}];
$scope.updateScroll = function(isLast){
if(isLast) Scroller.refresh()
} example: http://plnkr.co/edit/10U3ai?p=preview check console |
@Acido69 : thanks for ur help
My problem is that all li items are getting updated to view i guess and iscroll effect also seen but items are not visible !!!! if i stop using iscroll creation then all items are visible (or) if i dont use ng-repeat also all items are visible but with ng-repeat + iscroll the derivative part is not visible !!!! please help me |
Thanks for the dirty/fast solution @Acido69 ! |
Really surprised there is no event based solution to hook into the lifecycle of ng-repeat. |
Hi,
for the jquery-mobile-angular-adapter, I have the following use case:
jQuery Mobile has a listview widget. That widget is applied to
<ul>
tags and, beneath other things, sets the rounded corners of contained<li>
-items. I.e. the top most entry get rounded corners only at the top, entries in the middle don't get rounded corners, and the bottom entry gets rounded corners only at the bottom. After changes to the<li>
elements, one needs to call therefresh
function of the listview widget.When ng-repeat is used to create the
<li>
entries in the list, I have to problem of detecting changes.It would be great if angular could fire an event whenever ng-repeat, ng-switch, ng-options, or directives with a templateUrl change the dom, so that the adapter could afterwards refresh the corresponding container widgets like
listview
,checkboxradio
(for ng-options).Right now I have the following workaround:
I create additional directives that bind to the same elements as ng-repeat, ng-options, ng-switch, ..., watch the same value and trigger an event when the value changes. Especially for ng-options, this requires a lot of code duplication from the original angular directive....
I also noticed that ng-include already fires the
$contentLoaded
event. The same for the other directives would be great!Thanks,
Tobias
The text was updated successfully, but these errors were encountered: