{"action":"created","issue":{"url":"https://api.github.com/repos/lorenzofox3/Smart-Table/issues/366","labels_url":"https://api.github.com/repos/lorenzofox3/Smart-Table/issues/366/labels{/name}","comments_url":"https://api.github.com/repos/lorenzofox3/Smart-Table/issues/366/comments","events_url":"https://api.github.com/repos/lorenzofox3/Smart-Table/issues/366/events","html_url":"https://github.com/lorenzofox3/Smart-Table/issues/366","id":67541440,"number":366,"title":"Suppress initial call to st-pipe function / best way to handle url param for filter","user":{"login":"jugglingcats","id":526349,"avatar_url":"https://avatars.githubusercontent.com/u/526349?v=3","gravatar_id":"","url":"https://api.github.com/users/jugglingcats","html_url":"https://github.com/jugglingcats","followers_url":"https://api.github.com/users/jugglingcats/followers","following_url":"https://api.github.com/users/jugglingcats/following{/other_user}","gists_url":"https://api.github.com/users/jugglingcats/gists{/gist_id}","starred_url":"https://api.github.com/users/jugglingcats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jugglingcats/subscriptions","organizations_url":"https://api.github.com/users/jugglingcats/orgs","repos_url":"https://api.github.com/users/jugglingcats/repos","events_url":"https://api.github.com/users/jugglingcats/events{/privacy}","received_events_url":"https://api.github.com/users/jugglingcats/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-10T08:31:51Z","updated_at":"2015-04-10T08:58:15Z","closed_at":null,"body":"Our goal is to be able to pass in a filter criteria in the URL. This is to support proper back button behaviour. We are using UI Router but I think this requirement is fairly generic.\r\n\r\nTo get this working we've created an alternative st-search directive that just does a one way transfer from model to the table state, and it is working fine for us. However, we get multiple calls to the st-pipe function on page load. Once with empty filter and then another when the model is modified.\r\n\r\nWe're open to using a different approach, but we like using ng-model to hold the filter, because we can then watch for changes in the controller, etc. I think the model <--> table state sync was mentioned in another issue.\r\n\r\nOur directive looks like this:\r\n```\r\nangular.module('smart-table')\r\n.directive(\"stSearch2\", ['stConfig', '$timeout', '$log', function(stConfig, $timeout, $log) {\r\n        return {\r\n            require: '^stTable',\r\n            scope: {\r\n                predicate: '=?stSearch2',\r\n                ngModel: '='\r\n            },\r\n            link: function(scope, element, attr, ctrl) {\r\n                var tableCtrl=ctrl;\r\n                var throttle = attr.stDelay || stConfig.search.delay;\r\n\r\n                // model -> table state\r\n                scope.$watch('ngModel', function(newVal) {\r\n                    if ( newVal ) {\r\n                        $log.info(\"Model changed for search!!\", scope.predicate, newVal);\r\n                        tableCtrl.search(newVal, scope.predicate || '');\r\n                    }\r\n                });\r\n            }\r\n        }\r\n    }]);\r\n```\r\n\r\nYou can see example Plunkr here: http://plnkr.co/edit/FErRR0cgvdBduo94fYca?p=info. In the console you will see \"func called\" twice on page load.\r\n\r\nAny help much appreciated."},"comment":{"url":"https://api.github.com/repos/lorenzofox3/Smart-Table/issues/comments/91483656","html_url":"https://github.com/lorenzofox3/Smart-Table/issues/366#issuecomment-91483656","issue_url":"https://api.github.com/repos/lorenzofox3/Smart-Table/issues/366","id":91483656,"user":{"login":"lorenzofox3","id":2402022,"avatar_url":"https://avatars.githubusercontent.com/u/2402022?v=3","gravatar_id":"","url":"https://api.github.com/users/lorenzofox3","html_url":"https://github.com/lorenzofox3","followers_url":"https://api.github.com/users/lorenzofox3/followers","following_url":"https://api.github.com/users/lorenzofox3/following{/other_user}","gists_url":"https://api.github.com/users/lorenzofox3/gists{/gist_id}","starred_url":"https://api.github.com/users/lorenzofox3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorenzofox3/subscriptions","organizations_url":"https://api.github.com/users/lorenzofox3/orgs","repos_url":"https://api.github.com/users/lorenzofox3/repos","events_url":"https://api.github.com/users/lorenzofox3/events{/privacy}","received_events_url":"https://api.github.com/users/lorenzofox3/received_events","type":"User","site_admin":false},"created_at":"2015-04-10T08:58:15Z","updated_at":"2015-04-10T08:58:15Z","body":"yes there is a known bug https://github.com/lorenzofox3/Smart-Table/issues/329, st-pipe is called whenever the table state change and the pagination directive tends to change it when the table loads (st-sort as well with the st-sort-default attribute) I need to fix it. Your one direction flow is nice but you will likely face problems when you will need to rebuild the tablestate from an exetrnal source (like if you want to persist the state in local storage or sessions and rebuild the table from it)"}}