$compile function and replace

I had a problem with my code and by playing a little I found a solution but I have no idea why is it working. Here's the thing:

// recompile all audio buttons
angular.element(textAsDom).find('sound-button').each(function(key, element) {

I got a raw html as a parameter, and inside it I'm looking for directives named "soundButton" and I compile them in order to use their attached scope functions and properties.

However, my first solution was to do it like this:

 // recompile all audio buttons
 angular.element(textAsDom).find('sound-button').each(function(key, element) {
     var compiledSound = $compile(angular.element(element))(scope);


So I first compile the soundButton and link it to the scope and I got a bound element in return. Then I replace the original element with the bound element. But then all angular dirty checking nor event handlers don't work anymore.

As for now my problem is solved, however for the sake of understanding why it didn't work, I'm asking you guys if you can shed some lights about this esoteric stuff.



Sounds like you're approaching this a little weird.

Why not just wire up a directive to sound-button? No need to do .find.

.directive("sound-button", function(){
    return {
        class: 'C',
        replace: true,

Need Your Help

iOS 5 and facebook graph api

facebook login sdk ios5

I'm using the official facebook SDK for iOS, and the iOS 5 SDK.

This class does not support SAAJ 1.3

glassfish jax-ws weblogic-10.x liferay-6 java-6

In trying to call a webservice from a portlet from Glassfish to a webservice hosted remotely on weblogic we are getting this error:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.