.controller("Canned", ["$scope", "$firebaseArray","Data", function($scope, $firebaseArray, $ionicModal, Data) {
$scope.deleteItem = function(cannedLst) {
$scope.cannedLsts.$remove(cannedLst);
};
var cannedRef = new Firebase("https://pricemonitoringsys.firebaseio.com/dti")
$scope.cannedGoods = $firebaseArray(cannedRef);
var query = cannedRef.orderByChild("category").equalTo("canned");
$scope.cannedLsts = $firebaseArray(query);
}
])

我想将数据传递给此控制器,当我点击按钮但是在加载时它会触发工厂和我的控制器这就是为什么我总是最终没有取出任何东西,因为我的工厂什么也没有,我希望它在我点击时触发按钮有人请帮助我这是我的论文,我需要在星期一提交
.factory('Data', function(){
return { searchData: ''};
})
.controller('CompareModal', function($scope, $ionicModal, Data, $firebaseArray) {
$scope.compareMe = function(Data) {
console.log(Data)
Data.searchData = Data;
$scope.modal.show();
}
})
.controller("Compare", ["$scope", "$firebaseArray","Data", function($scope,$firebaseArray,Data) {
var x = angular.copy(Data.searchData);
console.log(x)
var cannedRef = new Firebase("https://pricemonitoringsys.firebaseio.com/store1")
$scope.cannedGoods = $firebaseArray(cannedRef);
var query = cannedRef.orderByChild("name").equalTo(x);
$scope.filteredMessages = $firebaseArray(query);
}
])

<ion-item class="col item-text-wrap" ng-controller="CompareModal">
<button class="button button-balanced button-small" ng-model="Data.searchData" ng-click="compareMe(Data.searchData = cannedLst.name)">₱ {{cannedLst.price}}</button>
</ion-item>
&#13;