I have been searching extensively for a solution to this issue without any luck. Any assistance in this matter would be highly appreciated.
Key Details:
- Using angular-material tabs
- When an item is selected from a dropdown, a request is sent to a firebase database and the response is stored in an array on the $scope.
- The HTML uses ng-repeat to display the response object.
The Challenge:
Although the response object exists in the scope, the HTML does not render anything until the user interacts with another button on the view – clicking any button triggers the rendering of results. In fact, simply touching/clicking something on the screen causes the results to show up.
If a user fetches data from the database for artists in a specific medium (like painting) but doesn’t interact with anything on the screen, no results are displayed despite the existence of the response object in $scope.
This issue has left me puzzled.
HTML Code:
<md-tabs md-dynamic-height md-border-bottom md-center-tabs><md-tab label="Artists">
<md-content id="tab_background" class="md-padding">
<div class="query_results hide_link" layout-padding>
<a ng-repeat="artist in results | filter: searchText"
href="/#/artist/{{artist.selectedMedium}}/{{artist.uid}}">
<md-card>
<img ng-src="{{artist.profImg}}" class="md-card-image" alt="Washed Out">
<md-card-header>
<div id="card_play_button_included">
<md-card-header-text>
<span class="hide_link md-title">{{artist.name}}{{artist.name_last}}</span>
<span class="hide_link md-subhead">{{artist.selectedSubmedium[0]}}</span>
<span class="hide_link md-caption">{{artist.neighborhood}}</span>
</md-card-header-text>
</div>
</md-card-header>
<md-card-actions layout="row" layout-align="end center">
</md-card-actions>
</md-card>
</a>
</div>
</md-content>
</md-tab>
<md-tab label="Events">
</md-tab>
</md-tabs>
Javascript Code:
$scope.getArtists = function(medium){
//resetting results array
$scope.firstArray = [];
$scope.results = [];
var Medium = medium.name;
firebase.database().ref('/Artists/' + Medium).once('value').then(function(snapshot){
console.log(snapshot.val());
var obj = snapshot.val();
for (var key in obj) {
var innerObj = obj[key]
innerObj.uid = key;
console.log(innerObj);
$scope.firstArray.push(innerObj);
}
$scope.results = $scope.firstArray;
$scope.runSpinner();
})
}