0
formApp.controller('load', function ($scope, ApiCall, $window, $http) {
$window.onload = function () {
    alert("the page loaded and will now call the function");
    ApiCall.GetApiCall("signOn", "GetSingleSignOn").success(function (data) {
        alert("successful call to singleSignOn, GetSingleSignOn");
        var data = $.parseJSON(JSON.parse(data));
        $scope.apiGetInfo = data;
        alert("successful call to singleSignOn, GetSingleSignOn");
        alert(data);
    });
};

This code works fine up to the var data- $.parseJson(JSON.parse(data));

I looked at some examples of how to do this in the Controller online and they all looked this way with $.parseJSON(JSON.parse(data)). It gives me: ReferenceError: $ is not defined

Not sure why as every example I looked at to call an API Controller in Angular showed this way.

2

1 Answer 1

1

You don't need the $.parseJSON. remove it and leave the JSON.parse intact:

var data = JSON.parse(data);

If you want to use JQuery ($) you have to import the script.

UPDATE:

if you want to redirect to an URL you can use $window:

$window.location.href = 'http://www.google.com';
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! Another question, the JSON parses out an HTML address, how can I in the controller go to that HTML page?
Thank you good sir I actually found that out right after I posted the comment, that's a piece of my project that is completed with this bit of information!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.