mankindsoftware / angular-isotope

AngularJS directives to easily work with JQuery Isotope.
http://mankindsoftware.github.io/angular-isotope
204 stars 79 forks source link

Pass multiple params to iso-method #27

Open that1guy opened 10 years ago

that1guy commented 10 years ago
 $scope.$emit('iso-method', {name:'layout', params:instance.elements[0], function(){
                console.log("done");
            }});

gives me error:

Uncaught SyntaxError: Unexpected token ( search.js:30
Error: [ng:areq] http://errors.angularjs.org/1.2.26/ng/areq?p0=searchController&p1=not%20aNaNunction%2C%20got%20undefined
    at Error (native)
    at http://localhost:8081/angular/angular.min.js:6:450
    at Db (http://localhost:8081/angular/angular.min.js:19:106)
    at Wa (http://localhost:8081/angular/angular.min.js:19:193)
    at http://localhost:8081/angular/angular.min.js:67:403
    at link (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-route.min.js:7:248)
    at N (http://localhost:8081/angular/angular.min.js:54:372)
    at g (http://localhost:8081/angular/angular.min.js:47:256)
    at http://localhost:8081/angular/angular.min.js:46:377
    at http://localhost:8081/angular/angular.min.js:48:217 

If I just don't pass in a callback function I get error:

TypeError: undefined is not a function
    at Object.i.Isotope._masonryLayout (http://localhost:8081/isotope/jquery.isotope.min.js:13:10124)
    at Object.i.Isotope.layout (http://localhost:8081/isotope/jquery.isotope.min.js:13:6548)
    at HTMLDivElement.<anonymous> (http://localhost:8081/isotope/jquery.isotope.min.js:13:15321)
    at Function.n.extend.each (http://localhost:8081/jquery/dist/jquery.min.js:2:2880)
    at n.fn.n.each (http://localhost:8081/jquery/dist/jquery.min.js:2:847)
    at i.fn.isotope (http://localhost:8081/isotope/jquery.isotope.min.js:13:15219)
    at k.$scope.updateMethod (http://localhost:8081/angular-isotope/dist/angular-isotope.js:94:31)
    at methodHandler (http://localhost:8081/angular-isotope/dist/angular-isotope.js:103:21)
    at http://localhost:8081/angular-isotope/dist/angular-isotope.js:122:14
    at k.$emit (http://localhost:8081/angular/angular.min.js:113:471) 

thanks for help.

jojobyte commented 10 years ago

That initial code has a typo, just fyi.

{
  name: 'layout',  
  params: instance.elements[0], 
  function(){} // this function has no paramater, so it will break the object
}
{
  name: 'layout',  
  params: instance.elements[0], 
  function: function(){} // this would be a proper object
  // using the word function as an attribute is bad form in JS last I checked
}