When matchList = [] is empty the button ng-disabled="checkIfDataExists" should be disabled. But when matchList = [] is full the button should be enabled. How to archive that? Thanks
Controller:
app.controller('gameplanController', ['currentAuth', '$scope', '$location', '$firebaseObject', '$firebaseArray', '$http', function (currentAuth, $scope, $location, $firebaseObject, $firebaseArray, $http) {
var ref = firebase.database().ref("matches");
var matchList = $firebaseObject(ref);
matchList.$loaded().then(function (data) {
$scope.checkIfDataExists = function () {
var matchList = [];
if(matchList.length === 0) {
console.log("empty");
$scope.checkIfDataExists = true
} else {
console.log("full");
$scope.checkIfDataExists = false
}
};
});
}]);
HTML:
<button type="button" class="btn btn-default button-main" ng-disabled="checkIfDataExists">{{ gametable }}</button>