简体   繁体   中英

pass data from mvc controller to angular controller

My requirement is how can I pass some data to my angular controller from my mvc controller. so that in the angular html view I can use that parameter and search the data from my web api service. as of now my angular view open as blank. and as per the user selection it fetch the data from the service.

but now I need to pass some default parameter on the load of html view.so it should open up with some data.

so I how can I do this.

Below is my controller code.

app.controller('SearchController', ['$scope','$http',function ($scope, $http) {
    $scope.sessionGuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    });
    $scope.searchValue = "";
    $scope.stockNumber = "";

    $scope.searchRequest = {
        Criteria: [],
        resultsTabIndex: 0,
        orderBy: "sortbypopularity"

    };

Thanks

Finaly I cookies. I create a cookie from my mvc action method and need to read from my angular controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM