• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

c# angularjs assistance

Joined
May 27, 2008
Messages
3,628 (0.62/day)
System Name Ultra 64
Processor NEC VR4300 (MIPS R4300i)
Motherboard proprietary design
Cooling Fanless aircooled
Memory 4.5MB 250 MHz RDRAM
Video Card(s) 62.5 MHz Reality Coprocessor
Storage 32 - 512 Mbit ROM Cartridge
Display(s) 720x576
Case Clear Blue Funtastic
Audio Device(s) 16-bit CD quality
Power Supply proprietary design
Mouse N64 mouse for use with N64DD
Keyboard N64 keyboard for use with N64DD
Hi all

Im doing some work in angularJS. Ive setup a web service which pulls and manipulates data from a database and angularjs is accessing the web service it through the url. Depending on the url the web service returns different data which is then displayed in various ways. This all works grand on a one off loading of the web page. However the data in the database and thus will be displayed will change without any interaction from this page. So i need angularJS to periodically call the urls. I can easily perform the logic afterwards to handle the data returned and checking if its changed etc. I just cannot for the life of me figure out how to call the service and make it reuturn data from the web service when i want it too.

CONTROLLER
Code:
app.controller('mainCtrl', function ($scope, TeamCityService) {
   
        TeamCityService.getDevBuildData(1).then(function (result) {
            $scope.DevToday = result.data.average;
            images(result.data.average, true, 1, result.data.buildNo, result.data.queavgerage);
        });

        TeamCityService.getDevBuildData(2).then(function (result) {
            $scope.DevCurrent = result.data.average;
            images(result.data.average, true, 2, result.data.buildNo, result.data.queavgerage);
        });

        TeamCityService.getDevBuildData(3).then(function (result) {
            $scope.DevWeek = result.data.average;
            images(result.data.average, true, 3, result.data.buildNo, result.data.queavgerage);
        });

        TeamCityService.getDevBuildData(4).then(function (result) {
            $scope.PrivateToday = result.data.average;
            images(result.data.average, false, 1, result.data.buildNo, result.data.queavgerage);
        });

        TeamCityService.getDevBuildData(5).then(function (result) {
            $scope.PrivateCurrent = result.data.average;
            images(result.data.average, false, 2, result.data.buildNo, result.data.queavgerage);
        });
        
      
            TeamCityService.getDevBuildData(6).then(function (result) {
                $scope.PrivateWeek = result.data.average;
                images(result.data.average, false, 3, result.data.buildNo, result.data.queavgerage);
            });
      

});

ive got the .factory in a seperate file if youd like that linked too
thanks all
 
Joined
May 27, 2008
Messages
3,628 (0.62/day)
System Name Ultra 64
Processor NEC VR4300 (MIPS R4300i)
Motherboard proprietary design
Cooling Fanless aircooled
Memory 4.5MB 250 MHz RDRAM
Video Card(s) 62.5 MHz Reality Coprocessor
Storage 32 - 512 Mbit ROM Cartridge
Display(s) 720x576
Case Clear Blue Funtastic
Audio Device(s) 16-bit CD quality
Power Supply proprietary design
Mouse N64 mouse for use with N64DD
Keyboard N64 keyboard for use with N64DD
ignore that i think ive done it.

Yup managed it. Im still working out why this time it worked im certain i tried this idea. But ive done that much googleing and trying different ideas i could have easily missed it. Sorry for the wasted post.

For anyone else who comes accross this looking for the same solution i did.

Code:
app.controller('mainCtrl', function ($scope, TeamCityService) {
    getstuff();
    function getstuff() {
        TeamCityService.getDevBuildData(1).then(function (result) {
            $scope.DevToday = result.data.average;
            images(result.data.average, true, 1, result.data.buildNo, result.data.queavgerage);
        });
       
        TeamCityService.getDevBuildData(2).then(function (result) {
            $scope.DevCurrent = result.data.average;
            images(result.data.average, true, 2, result.data.buildNo, result.data.queavgerage);
        });

        TeamCityService.getDevBuildData(3).then(function (result) {
            $scope.DevWeek = result.data.average;
            images(result.data.average, true, 3, result.data.buildNo, result.data.queavgerage);
        });

        TeamCityService.getDevBuildData(4).then(function (result) {
            $scope.PrivateToday = result.data.average;
            images(result.data.average, false, 1, result.data.buildNo, result.data.queavgerage);
        });

        TeamCityService.getDevBuildData(5).then(function (result) {
            $scope.PrivateCurrent = result.data.average;
            images(result.data.average, false, 2, result.data.buildNo, result.data.queavgerage);
        });
        
      
            TeamCityService.getDevBuildData(6).then(function (result) {
                $scope.PrivateWeek = result.data.average;
                images(result.data.average, false, 3, result.data.buildNo, result.data.queavgerage);
            });
            setTimeout(getstuff, 4000);
            console.log(1);
        }

Most likely not the best solution but it works. I cannot believe how simple it is compared to how long it took me to think of trying it :shadedshu

EDIT:

Awwwdam i realised why it didnt work when i first tried it. When i called the function from the setTimeout object i added the brackets causing it to go a little berserk.
 
Last edited:
Top