为什么我的数据仅在手动重新加载页面后才会显示-AngularJs

时间:2018-08-17 15:53:31

标签: c# asp.net angularjs asp.net-web-api

你好,我正在使用Angularjs构建一个ASP.NET Web API,C#。我在html页面中加载公司信息时遇到问题。问题是仅在手动刷新页面后才显示信息。如果没有手动刷新,将显示公司页面,但没有从angularjs控制器发送的信息

angularjs

var WorkSpaceController = function ($scope, $http, $location, $window) {

    $scope.workSpace;
    $scope.SearchResult = function () {

        var JsonObj = {};
        var qs = $location.search();
        //alert(qs["id"]);
        var qs_id = qs["id"];

        //var User = JSON.stringify(jsonObj);
        JsonObj["workSpaceID"] = qs_id;

        jQuery.ajax({
            type: "GET",
            url: "/api/Company/GetWorkSpaceById",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: JsonObj,
            success: function (response) {

                $scope.workSpace = response;

            }
        });

    };
    $scope.SearchResult();
};
WorkSpaceController.$inject = ['$scope', '$http', '$location', '$window'];

**
**


<section class="parallax-section" data-scrollax-parent="true">
    <div class="bg par-elem " data-bg="images/bg/1.jpg" data-scrollax="properties: { translateY: '30%' }"></div>
    <div class="overlay"></div>
    <div class="container">
        <div class="section-title center-align">
            <h2><span>WELCOME TO {{workSpace.Name}}</span></h2>
            <div class="breadcrumbs fl-wrap"><a href="#">Home</a><a href="#">Listings</a><span>Listings Without Map</span></div>
            <span class="section-separator"></span>
        </div>
    </div>
    <div class="header-sec-link">
        <div class="container"><a href="#" class="custom-scroll-link">Let's Start</a></div>
    </div>
</section>
<!--  section  end-->
<!--  section  -->
<section class="gray-bg no-pading no-top-padding" id="sec1">
    <div class="col-list-wrap fh-col-list-wrap  left-list">
        <div class="container">
            <div class="row">
                <div class="col-md-8">
                    <div class="listsearch-header fl-wrap">
                        <h3>Results For : <span>All Listings</span></h3>
                        <div class="listing-view-layout">
                            <ul>
                                <!--<li><a class="grid active" href="#"><i class="fa fa-th-large"></i></a></li>-->
                                <!--<li><a class="list" href="#"><i class="fa fa-list-ul"></i></a></li>-->
                            </ul>
                        </div>
                    </div>





                    <!-- list-main-wrap-->
                    <div class="list-main-wrap fl-wrap card-listing" ng-repeat="sts in workSpace.Stands">

                        <div class="listing-item">
                            <!--ng-repeat="wss in workSpace.Stands"-->
                            <div>
                                <article class="geodir-category-listing fl-wrap">
                                    <div class="geodir-category-img">
                                        <img src="../../Images/1.jpg" alt="">
                                        <div class="overlay"></div>
                                        <!--<div class="list-post-counter"><span>15</span><i class="fa fa-heart"></i></div>-->
                                    </div>
                                    <div class="geodir-category-content fl-wrap">
                                        <a class="listing-geodir-category" href="/#/U_Orders?id={{sts.ID}}">ORDER</a>
                                        <div class="listing-avatar">
                                            <a href="author-single.html"><img src="../../Images/1.jpg" alt=""></a>
                                            <span class="avatar-tooltip">{{workSpace.Name}}<strong>{{workSpace.Name}}</strong></span>
                                        </div>
                                        <h3><a href="listing-single.html">{{sts.Name}}</a></h3>
                                        <p>{{sts.Description}}</p>
                                        <div class="geodir-category-options fl-wrap">
                                            <div class="listing-rating card-popup-rainingvis" data-starrating2="4">
                                                <span>{{sts.Size}}SIZE</span>
                                            </div>
                                            <div class="geodir-category-location"><a href="#">{{sts.Address.City}}</a></div>
                                        </div>
                                    </div>
                                </article>
                            </div>
                        </div>
                    </div>


                </div>

            </div>
        </div>
    </div>
</section>


<a class="to-top"><i class="fa fa-angle-up"></i></a>

0 个答案:

没有答案