Angular+Chosen remote data source

303 views Asked by At

I am using https://github.com/localytics/angular-chosen for an angular chosen box application with remote loading as in the example.

angular.module('App', ['ngResource', 'localytics.directives'])
.controller('BeerCtrl', function($scope) {
  $scope.beers = $resource('api/beers').query()
});

My controller is a controller connected to a view which only comes into play when a user clicks the edit button:

    <div id='modal' ng-switch on="modal">
            <div ng-switch-when="view" ng-include="'view.url'"></div
            <div ng-switch-when="edit" ng-controller="BeerCtrl" ng-include="'edit.url'"></div>
    </div>

This does not work (does not load options into chosen select -- options are however available and even visible in the DOM in the original "select" box).

However, when I move the ng-controller tag to the #modal div, it does work, however, it calls the resource on page load which is a waste since I only need the options loaded (many!) if the edit modal is opened.

Any help is appreciated. Thanks

0

There are 0 answers