javascripts(来自局部视图)无法在角度js页面中工作(主视图)

时间:2016-06-18 07:52:55

标签: javascript asp.net angularjs

我正在制作一个asp.net MVC客户端应用程序,它有一个" mainpage.cshtml"在Angularjs上运行。我有一个控制器动作,单击按钮会返回部分视图(orgdetailsview.cshtml)到" mainpage.cshtml"。问题是" orgdetailsview.cshtml"中的javascripts。当他们最终被嵌入" mainpage.cshtml"点击按钮。

为了让事情有效,我复制了#34; orgdetailsview.cshtml" " mainpage.cshtml"中的脚本。脚本现在正在工作,但在控制台跟踪错误显示

Error: [$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.5.6/$rootScope/inprog?p0=%24digest

这是我的" orgdetailsview.cshtml"

<div style="text-align:center;background-color: #dfdf00 ;font-size:18px;"><b>ORGANIZATION DETAILS</b></div>

<div style="padding-top:7px;width:100%;overflow:scroll;text-align:center" id="outputorgdetails">
<a id="mainorgbutton" class="btn-circle">+</a> <span class="buttonheadings">&nbsp;&nbsp;&nbsp;&nbsp;Main Organization Details</span>
<button id="clickme" onclick="myfunction()">click</button>
</div>

这是&#34; mainpage.cshtml&#34;

 <script>

var app = angular.module("myapp", ['ngSanitize']);
app.controller('myctrl', ['$scope', '$http', '$sce', function ($scope, $http, $sce) {

    $scope.gobutton = function () {

        $scope.userdetails = $sce.trustAsHtml("<img src='http://api.ning.com/files/wdDZeipuIRydeFO-o32jfjGVFK5H7DEvHdNew3CRBmmFjYGmg-B1KXAU-R3CYL3tDZJSc67U*jacIZY9Fc*dCLMOOySBoVMA/circleloadinganimation.gif'  width='300' text-align='center'/>");
        $scope.personaids = $sce.trustAsHtml("<img src='http://api.ning.com/files/wdDZeipuIRydeFO-o32jfjGVFK5H7DEvHdNew3CRBmmFjYGmg-B1KXAU-R3CYL3tDZJSc67U*jacIZY9Fc*dCLMOOySBoVMA/circleloadinganimation.gif'  width='300' text-align='center'/>");


        $http.get('/profile/userdetails/' + $scope.uidng).success(
            function (response) {
                $scope.userdetails = $sce.trustAsHtml(response);
            },
            function (failure)
            { console.log("failed :(", failure); });

        $http.get('/profile/orgdetailsview').success(
            function (response) {
                $scope.orgdetails = $sce.trustAsHtml(response);
                alert($scope.orgdetails);
            },
            function (failure)
            { console.log("failed :(", failure); });            

    }
}
]);

</script>

<div ng-app="myapp" ng-controller="myctrl">
<!--this is header on top-->
<div id="header" style="padding:10px;background-color: rgb(0, 50, 150)">
<div align="center" style="font-family:'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;font-size:30px;color: #ffffff "><b>VOL User Profile</b></div>
</div>
<hr align="left" width="100%">

<div name="belowheader">
    <div id="inputarea" style="text-align:center">
        <span style="font-size:23px"> Enter User ID : </span><input type="text" ng-model="uidng" placeholder="user id" style="padding:2px">
        <a class="myButton" ng-click="gobutton()">GO</a>
    </div>
    <br />

    <div id="output" style="padding-top:25px">
        <div style="width:50%;float:left">
            <div class="outputboxes" ng-bind-html="userdetails"></div>
        </div>
        <div ng-bind-html="orgdetails" style="width:45%;float:left;padding-left:50px"></div>

    </div>
</div>

@*script from "orgdetailsview.cshtml"*@
<script>
function myfunction() {
    alert("function working");
    @*alert(@VOluserprofile.UI.Models.personas.a);*@
    $.ajax({
        url: "/profile/orgdetails/" + @VOluserprofile.UI.Models.personas.a,
        success: function (data) {
            alert(data);
        }
    });
}
alert("script working");

</script>

第二个问题是&#34; VOluserprofile.UI.Models.personas.a&#34;当&#34; usersdetails&#34;被分配给一个静态类。 angularjs脚本中的ajax成功完成...但它在控制台中显示错误无法读取&#34; ordetailsview.cshtml&#34;脚本。

这是正确的做事方法还是只使用角度而不使用局部视图的更好解决方案。

0 个答案:

没有答案