Skip to content

Double child $compile() issue #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
charlypoly opened this issue Jun 11, 2014 · 6 comments
Open

Double child $compile() issue #7

charlypoly opened this issue Jun 11, 2014 · 6 comments

Comments

@charlypoly
Copy link
Contributor

With this template :

<!doctype html>
<html lang="en">
<head>
   <!-- ... -->
   <script type="text/javascript" src="../bower_components/angular-sanitize/angular-sanitize.js"></script>
   <script type="text/javascript">
      var app = angular.module('app', ['coq','ngResource']);

      app.factory('TeamsModel', function($resource, Coq) {
        return Coq.factory({
           $resource : $resource('/teams/:id'),
           $attributes : {
             id   : 'number',
             name : 'text'
           }
        });
      });

      app.controller('myController', function($scope, TeamsModel) {
         $scope.team2 = new TeamsModel();
      });
   </script>
</head>
<body ng-app="app">
  <div ng-controller="myController">
      <form coq-model="team2" ng-model="myForm">
        <p>Name : <input coq-model-attribute="name"></p>

        <input type="submit" ng-click="team2.save()">
    </form>
  </div>
</body>
</html>
@charlypoly charlypoly added this to the Bugs milestone Jun 11, 2014
@charlypoly charlypoly self-assigned this Jun 11, 2014
@charlypoly
Copy link
Contributor Author

this is caused by the double-$compile from coq-model directive that make function "binded" to ng-click to be registred as listener twice..

@charlypoly
Copy link
Contributor Author

Need a real fix

@charlypoly
Copy link
Contributor Author

Introduction

CoqModel inserts many <input coq-model-attribute="..." /> in current element

CoqModelAttribute need parent element with CoqModel

CoqModel add to current element type, ng-model attributes

Problem

CoqModel does one $compile in pre-link and one in post-link.
Removing the second $compile in post-link will make ng-model failed to link..

@charlypoly
Copy link
Contributor Author

Posted on StackOverflow..

@charlypoly
Copy link
Contributor Author

angular/angular.js#8536 related ?

@charlypoly charlypoly changed the title ng-click="model.save()" make 2 XHR call Double child $compile() issue Aug 8, 2014
@charlypoly
Copy link
Contributor Author

A solution to test : http://sporto.github.io/blog/2013/06/24/nested-recursive-directives-in-angular/#comment-991048825

$compile('<collection collection="member.children"></collection>')(scope, function(cloned, scope){
   element.append(cloned); 
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant