Skip to content

Instantly share code, notes, and snippets.

@msadoon
Created October 24, 2014 00:56
Show Gist options
  • Save msadoon/11361575c735699d9e06 to your computer and use it in GitHub Desktop.
Save msadoon/11361575c735699d9e06 to your computer and use it in GitHub Desktop.
angular.js
var bugSummaryApp = angular.module('bugSummaryApp', []);
bugSummaryApp.factory('bugFactory', function($http) {
var webserviceURL = "/invokeWebService?webserviceHost=http://trceit-dev-env.elasticbeanstalk.com:8080&webservicePathURL=/getData";
var filteredResponse = [];
var bugFactory = {
async: function() {
var promise = $http.get(webserviceURL).then(function (response) {
angular.forEach(response.data, function(bug)
{
if (angular.isDefined(bug.OSVersion) && angular.isDefined(bug.appName) && angular.isDefined(bug.appVersion) && angular.isDefined(bug.deviceName))
{
filteredResponse.push(bug)
}
});
return filteredResponse;
});
return promise;
}
};
return bugFactory;
});
bugSummaryApp.service('bugService', function(bugIn) {
this.bug = bugIn;
});
bugSummaryApp.controller('bugSummaryCtrl1', function(bugService, bugFactory, $scope){
bugFactory.async().then(function(d) {
$scope.bugs = d
});
$scope.idSelectedBug = null;
var ddt = null;
$scope.setSelected = function (idSelectedBug) {
$scope.data = idSelectedBug;
bugService($scope.data);
};
});
bugSummaryApp.controller('bugDetailCtrl1', function(bugService, $scope){
$scope.bugService = bugService;
});
@sanfords
Copy link

bugSummaryApp.factory('bugService', [function() {
    var utils = {
        bug : 0,
    };

    utils.setBug = function(bugIn) {
        utils.bug = bugIn;
    }

    return utils;
}]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment