{"action":"created","issue":{"url":"https://api.github.com/repos/machineboy2045/angular-selectize/issues/66","labels_url":"https://api.github.com/repos/machineboy2045/angular-selectize/issues/66/labels{/name}","comments_url":"https://api.github.com/repos/machineboy2045/angular-selectize/issues/66/comments","events_url":"https://api.github.com/repos/machineboy2045/angular-selectize/issues/66/events","html_url":"https://github.com/machineboy2045/angular-selectize/issues/66","id":71272337,"number":66,"title":"How to add optgroups from json data??","user":{"login":"atheleron","id":6204881,"avatar_url":"https://avatars.githubusercontent.com/u/6204881?v=3","gravatar_id":"","url":"https://api.github.com/users/atheleron","html_url":"https://github.com/atheleron","followers_url":"https://api.github.com/users/atheleron/followers","following_url":"https://api.github.com/users/atheleron/following{/other_user}","gists_url":"https://api.github.com/users/atheleron/gists{/gist_id}","starred_url":"https://api.github.com/users/atheleron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atheleron/subscriptions","organizations_url":"https://api.github.com/users/atheleron/orgs","repos_url":"https://api.github.com/users/atheleron/repos","events_url":"https://api.github.com/users/atheleron/events{/privacy}","received_events_url":"https://api.github.com/users/atheleron/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-04-27T12:39:03Z","updated_at":"2015-05-15T11:12:20Z","closed_at":null,"body":"it would be nice to add **optgroups** to selectize like this\r\n```js\r\n<selectize config='myConfig' options='myOptions' optgroups='myOptgroups' ng-model=\"myModel\"></selectize>\r\n```\r\n\r\nI tried to add them trough config manualy like this and it works but\r\n\r\n```js\r\n\r\n\r\n$scope.optLis= [\r\n            {id: 1, title: 'Game of Thrones'},\r\n            {id: 2, title: 'Bird'},\r\n            {id: 3, title: 'Reptile'}\r\n        ];\r\n\r\n$scope.myConfig = {\r\n            optgroupField: 'parent_id',\r\n            optgroupLabelField: 'title',\r\n            optgroupValueField: 'id',\r\n            optgroups: $scope.optList,\r\n            valueField: 'id',\r\n            labelField: 'title',\r\n            searchField: 'title',\r\n            placeholder: 'Select Parent Category',\r\n            maxItems: 1,\r\n            preload: true\r\n        };\r\n```\r\n\r\nwhen I try to load optgroups in myConfig from database with json request by adding  **optgroups: $scope.roots** it doesnt work\r\n \r\n```js\r\n $scope.roots = function(){\r\n            return {\r\n                get : function() {\r\n                    return $http.get('/roots');\r\n                }\r\n            }\r\n};\r\n```\r\n\r\nI guess problem with this is preloading of roots inside angularjs becouse when i add myOptions to selectize tag from json they get loaded but optgroups didnt load inside angular so there is nothing\r\n"},"comment":{"url":"https://api.github.com/repos/machineboy2045/angular-selectize/issues/comments/102371905","html_url":"https://github.com/machineboy2045/angular-selectize/issues/66#issuecomment-102371905","issue_url":"https://api.github.com/repos/machineboy2045/angular-selectize/issues/66","id":102371905,"user":{"login":"atheleron","id":6204881,"avatar_url":"https://avatars.githubusercontent.com/u/6204881?v=3","gravatar_id":"","url":"https://api.github.com/users/atheleron","html_url":"https://github.com/atheleron","followers_url":"https://api.github.com/users/atheleron/followers","following_url":"https://api.github.com/users/atheleron/following{/other_user}","gists_url":"https://api.github.com/users/atheleron/gists{/gist_id}","starred_url":"https://api.github.com/users/atheleron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atheleron/subscriptions","organizations_url":"https://api.github.com/users/atheleron/orgs","repos_url":"https://api.github.com/users/atheleron/repos","events_url":"https://api.github.com/users/atheleron/events{/privacy}","received_events_url":"https://api.github.com/users/atheleron/received_events","type":"User","site_admin":false},"created_at":"2015-05-15T11:12:20Z","updated_at":"2015-05-15T11:12:20Z","body":"I just created a plunk I head bit trouble with 2 angular-selectize scripts on same page so I did some changes to suppot both directives **selectize** and **optselect** but now its ok check the preview on plank http://plnkr.co/edit/2JG0EEKbLQnpVbXjWpLg?p=info"}}