I'm using the Angular select-ui module on a rails app. I'm rendering a modal that most of the time renders correctly, but occasionally, it renders and looks like the below, there is some kind of error that i don't totally understand.
Notice the angular code being displayed as though there was a problem while the page was being rendered.
the modal normally looks like,
Oddly, closing the modal and re-accessing it, without a roundtrip to the server will fix this problem, so maybe the problem is tied to the dom needing to be completely loaded? As best as I can tell, even if the scope holding the tag data is empty, the form will still render without issue.
based on the html code,
<div class='form-group'>
<label for="inputEmail3" class="col-sm-3 control-label">Company</label>
<div class="col-sm-9">
<ui-select multiple ng-model="article.companies" ng-disabled="disabled">
<ui-select-match placeholder="Tag with related Companies...">{{ $item.name || "something" }}</ui-select-match>
<ui-select-choices repeat="company in allCompanies | filter: {'name': $select.search}" >
<small>
{{company.name}}
</small>
</ui-select-choices>
</ui-select>
</div>
</div>
I have a specific controller controlling the showing of the modal,
controllers.controller('articleSubmitModal', ($scope, $modal) ->
$scope.open = (size) ->
modalInstance = $modal.open(
templateUrl: 'ng-views/url_submit_modal.html'
controller: 'articleSubmitCtrl'
size: size
)
)
And the controller populating data into the select fields,
controllers.controller('articleSubmitCtrl', ($scope, $modalInstance, Company, Interface, Article, Community, Cause) ->
$scope.cancel = () ->
$modalInstance.dismiss('cancel');
$scope.allCompanies = []
Company.getAll().then (allCompanies) ->
$scope.allCompanies = JSON.parse allCompanies
$scope.allCommunities = []
Community.getAll().then (allCommunities) ->
$scope.allCommunities = JSON.parse allCommunities
$scope.allCauses = []
Cause.getAll().then (allCauses) ->
$scope.allCauses = JSON.parse allCauses
which is backed by services that look like,
.factory 'Company', ($q, $http) ->
Company =
getAll: () ->
$http
method: 'get'
url: '/api/companies'
.then (response) ->
response.data.list
return Company
.factory 'Community', ($q, $http) ->
Community =
getAll: () ->
$http
method: 'get'
url: '/api/communities'
.then (response) ->
response.data.list
return Community
.factory 'Cause', ($q, $http) ->
Cause =
getAll: () ->
$http
method: 'get'
url: '/api/causes'
.then (response) ->
response.data.list
return Cause
the chrome errors being rendered when this bug occurs are below. I'm not entirely certain how to look into this problem at a more granular level without digging into the angular select library, which i'd tend to avoid at this stage of the debugging process. How might I proceed?
angular.js?body=1:4734 Error: [ui.select:transcluded] Expected 1 .ui-select-choices but got '0'.
at http://localhost:3000/assets/select.js?body=1:187:14
at http://localhost:3000/assets/select.js?body=1:1064:21
at publicLinkFn (http://localhost:3000/assets/angular.js?body=1:2721:15)
at boundTranscludeFn (http://localhost:3000/assets/angular.js?body=1:2799:20)
at controllersBoundTransclude (http://localhost:3000/assets/angular.js?body=1:3218:22)
at link (http://localhost:3000/assets/select.js?body=1:1053:11)
at invokeLinkFn (http://localhost:3000/assets/angular.js?body=1:3503:13)
at nodeLinkFn (http://localhost:3000/assets/angular.js?body=1:3203:15)
at http://localhost:3000/assets/angular.js?body=1:3344:15
at processQueue (http://localhost:3000/assets/angular.js?body=1:5829:29) <div class="ui-select-container ui-select-multiple ui-select-bootstrap dropdown form-control ng-pristine ng-untouched ng-valid ng-scope" ng-class="{open: $select.open}" multiple="multiple" ng-model="article.companies" ng-disabled="disabled">
angular.js?body=1:4734 Error: [ui.select:transcluded] Expected 1 .ui-select-choices but got '0'.
at http://localhost:3000/assets/select.js?body=1:187:14
at http://localhost:3000/assets/select.js?body=1:1064:21
at publicLinkFn (http://localhost:3000/assets/angular.js?body=1:2721:15)
at boundTranscludeFn (http://localhost:3000/assets/angular.js?body=1:2799:20)
at controllersBoundTransclude (http://localhost:3000/assets/angular.js?body=1:3218:22)
at link (http://localhost:3000/assets/select.js?body=1:1053:11)
at invokeLinkFn (http://localhost:3000/assets/angular.js?body=1:3503:13)
at nodeLinkFn (http://localhost:3000/assets/angular.js?body=1:3203:15)
at http://localhost:3000/assets/angular.js?body=1:3344:15
at processQueue (http://localhost:3000/assets/angular.js?body=1:5829:29) <div class="ui-select-container ui-select-multiple ui-select-bootstrap dropdown form-control ng-pristine ng-untouched ng-valid ng-scope" ng-class="{open: $select.open}" multiple="multiple" ng-model="article.communities">
angular.js?body=1:4734 Error: [ui.select:transcluded] Expected 1 .ui-select-choices but got '0'.
at http://localhost:3000/assets/select.js?body=1:187:14
at http://localhost:3000/assets/select.js?body=1:1064:21
at publicLinkFn (http://localhost:3000/assets/angular.js?body=1:2721:15)
at boundTranscludeFn (http://localhost:3000/assets/angular.js?body=1:2799:20)
at controllersBoundTransclude (http://localhost:3000/assets/angular.js?body=1:3218:22)
at link (http://localhost:3000/assets/select.js?body=1:1053:11)
at invokeLinkFn (http://localhost:3000/assets/angular.js?body=1:3503:13)
at nodeLinkFn (http://localhost:3000/assets/angular.js?body=1:3203:15)
at http://localhost:3000/assets/angular.js?body=1:3344:15
at processQueue (http://localhost:3000/assets/angular.js?body=1:5829:29) <div class="ui-select-container ui-select-multiple ui-select-bootstrap dropdown form-control ng-pristine ng-untouched ng-valid ng-scope" ng-class="{open: $select.open}" multiple="multiple" ng-model="article.causes">
angular.js?body=1:4734 TypeError: Cannot read property 'source' of undefined
at Array.<anonymous> (http://localhost:3000/assets/select.js?body=1:857:44)
at Object.ngModelWatch (http://localhost:3000/assets/angular.js?body=1:8391:42)
at Scope.$digest (http://localhost:3000/assets/angular.js?body=1:6290:46)
at Scope.$apply (http://localhost:3000/assets/angular.js?body=1:6389:28)
at done (http://localhost:3000/assets/angular.js?body=1:3889:28)
at completeRequest (http://localhost:3000/assets/angular.js?body=1:4016:9)
at XMLHttpRequest.requestLoaded (http://localhost:3000/assets/angular.js?body=1:3981:11)
angular.js?body=1:4734 TypeError: Cannot read property 'length' of undefined
at ctrl.getPlaceholder (http://localhost:3000/assets/select.js?body=1:500:43)
at $parseFunctionCall (http://localhost:3000/assets/angular.js?body=1:5365:31)
at Object.expressionInputWatch (http://localhost:3000/assets/angular.js?body=1:5640:35)
at Scope.$digest (http://localhost:3000/assets/angular.js?body=1:6290:46)
at Scope.$apply (http://localhost:3000/assets/angular.js?body=1:6389:28)
at done (http://localhost:3000/assets/angular.js?body=1:3889:28)
at completeRequest (http://localhost:3000/assets/angular.js?body=1:4016:9)
at XMLHttpRequest.requestLoaded (http://localhost:3000/assets/angular.js?body=1:3981:11)
angular.js?body=1:4734 TypeError: Cannot read property 'source' of undefined
at Array.<anonymous> (http://localhost:3000/assets/select.js?body=1:857:44)
at Object.ngModelWatch (http://localhost:3000/assets/angular.js?body=1:8391:42)
at Scope.$digest (http://localhost:3000/assets/angular.js?body=1:6290:46)
at Scope.$apply (http://localhost:3000/assets/angular.js?body=1:6389:28)
at done (http://localhost:3000/assets/angular.js?body=1:3889:28)
at completeRequest (http://localhost:3000/assets/angular.js?body=1:4016:9)
at XMLHttpRequest.requestLoaded (http://localhost:3000/assets/angular.js?body=1:3981:11)
angular.js?body=1:4734 TypeError: Cannot read property 'length' of undefined
at ctrl.getPlaceholder (http://localhost:3000/assets/select.js?body=1:500:43)
at $parseFunctionCall (http://localhost:3000/assets/angular.js?body=1:5365:31)
at Object.expressionInputWatch (http://localhost:3000/assets/angular.js?body=1:5640:35)
at Scope.$digest (http://localhost:3000/assets/angular.js?body=1:6290:46)
at Scope.$apply (http://localhost:3000/assets/angular.js?body=1:6389:28)
at done (http://localhost:3000/assets/angular.js?body=1:3889:28)
at completeRequest (http://localhost:3000/assets/angular.js?body=1:4016:9)
at XMLHttpRequest.requestLoaded (http://localhost:3000/assets/angular.js?body=1:3981:11)
angular.js?body=1:4734 TypeError: Cannot read property 'source' of undefined
at Array.<anonymous> (http://localhost:3000/assets/select.js?body=1:857:44)
at Object.ngModelWatch (http://localhost:3000/assets/angular.js?body=1:8391:42)
at Scope.$digest (http://localhost:3000/assets/angular.js?body=1:6290:46)
at Scope.$apply (http://localhost:3000/assets/angular.js?body=1:6389:28)
at done (http://localhost:3000/assets/angular.js?body=1:3889:28)
at completeRequest (http://localhost:3000/assets/angular.js?body=1:4016:9)
at XMLHttpRequest.requestLoaded (http://localhost:3000/assets/angular.js?body=1:3981:11)
9angular.js?body=1:4734 TypeError: Cannot read property 'length' of undefined
at ctrl.getPlaceholder (http://localhost:3000/assets/select.js?body=1:500:43)
at $parseFunctionCall (http://localhost:3000/assets/angular.js?body=1:5365:31)
at Object.expressionInputWatch (http://localhost:3000/assets/angular.js?body=1:5640:35)
at Scope.$digest (http://localhost:3000/assets/angular.js?body=1:6290:46)
at Scope.$apply (http://localhost:3000/assets/angular.js?body=1:6389:28)
at done (http://localhost:3000/assets/angular.js?body=1:3889:28)
at completeRequest (http://localhost:3000/assets/angular.js?body=1:4016:9)
at XMLHttpRequest.requestLoaded (http://localhost:3000/assets/angular.js?body=1:3981:11)
6angular.js?body=1:4734 TypeError: Cannot read property 'length' of undefined
at ctrl.getPlaceholder (http://localhost:3000/assets/select.js?body=1:500:43)
at $parseFunctionCall (http://localhost:3000/assets/angular.js?body=1:5365:31)
at Object.expressionInputWatch (http://localhost:3000/assets/angular.js?body=1:5640:35)
at Scope.$digest (http://localhost:3000/assets/angular.js?body=1:6290:46)
at Scope.$apply (http://localhost:3000/assets/angular.js?body=1:6389:28)
at HTMLDivElement.<anonymous> (http://localhost:3000/assets/angular.js?body=1:8900:25)
at HTMLDivElement.jQuery.event.dispatch (http://localhost:3000/assets/jquery.js?body=1:2641:98)
at HTMLDivElement.elemData.handle (http://localhost:3000/assets/jquery.js?body=1:2448:135)