Im пытается добавить еще одну функцию к моему контроллеру, но он продолжает разрывать контроллер.добавление нескольких функций в один контроллер угловой
вот мой код:
.controller('ClimbController', [
\t '$scope', '$stateParams', 'Climbs', function(
\t $scope, $stateParams, Climbs) {
\t \t var climb_id = $stateParams.climbId;
\t \t var areaId = $stateParams.areaId;
\t \t if (!isNaN(climb_id)) {
\t \t \t climb_id = parseInt(climb_id);
\t \t }
\t \t if (!isNaN(areaId)) {
\t \t \t areaId = parseInt(areaId);
\t \t }
\t \t $scope.selected_ = {};
\t \t $scope.items = [];
\t \t $scope.details = true;
\t \t // looping though all data and get particular product
\t \t $scope.selectClimb = function(areas){
\t \t \t areas.forEach(function(data) {
\t \t \t if(data._id == climb_id){
\t \t \t \t $scope.selected_ = data;
\t \t \t }
\t \t \t });
\t \t }
\t \t // get all posts // try some function to get a single produt from server
\t \t $scope.getPosts = function(){
\t \t \t Climbs.getPosts()
\t \t \t .success(function (data) {
\t \t \t \t // data = feed.json file
\t \t \t \t var climbs = [];
\t \t \t \t data.areas.map(function(area) {
\t \t \t \t \t if (area._id === areaId) {
\t \t \t \t \t \t climbs = area.climbs;
\t \t \t \t \t }
\t \t \t \t });
\t \t \t \t $scope.selectClimb(climbs);
\t \t \t })
\t \t \t .error(function (error) {
\t \t \t \t $scope.items = [];
\t \t \t });
\t \t }
\t \t $scope.getPosts();
}
])
И определяется, чтобы добавить это к нему:
.controller('MyCtrl', function($scope, $ionicModal) {
$ionicModal.fromTemplateUrl('test-modal.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
});
$scope.openModal = function() {
$scope.modal.show();
};
$scope.closeModal = function() {
$scope.modal.hide();
};
//Cleanup the modal when we're done with it!
$scope.$on('$destroy', function() {
$scope.modal.remove();
});
// Execute action on hide modal
$scope.$on('modal.hidden', function() {
// Execute action
});
// Execute action on remove modal
$scope.$on('modal.removed', function() {
// Execute action
});
});
Когда я пытаюсь добавить это в код он ее нарушает. Я хотел бы добавить его как другую функцию или что-то еще, чтобы добавить ее в код.
Большое спасибо
, что ломает ?? вы хотите включить 'Myctrl' все функции в контроллер? –