$ scope变量被复制,未在Kendo-UI窗口中引用

时间:2014-10-10 11:51:52

标签: angularjs kendo-ui

我遇到的情况是我将$ scope变量传递到Kendo-UI窗口,并且正在进行任何更改

所有这些都在一个控制器中。

所以在我的主控制器中,我有一个$ scope.searchTerm变量,我初始化为“输入搜索词”..

在我的HTML中,我在主控制器上调用如下的peopleSearch.open()

<td><span>GSP</span><span ng-click="peopleSearch.open()" style="font-size:8pt;" class="glyphicon glyphicon-plus-sign"></span><td>                                       

这只是打开下面声明的这个kendo-ui窗口,并由同一个控制器覆盖:

<div kendo-window="peopleSearch" k-title="'Person Search'"
                            k-width="900" k-height="500" k-visible="false"
                            k-content="{ url: 'parts/peopleSearch.html' }"
                            k-on-open="peopleSearchVisible = true" k-on-close="peopleSearchVisible = false"
                            k-modal="true"></div>

同一控制器覆盖的Kendo-UI窗口模板如下所示。请注意,有一个输入绑定到$ scope.searchTerm。当窗口打开时,输入初始化为“输入搜索词”...因此它显然绑定了$ scope.searchTerm变量。

<section>
<div class="myAlerts">
        <alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)" >{{alert.msg}}</alert>
</div>  
<div>People Search</div><br/>
<div>{{searchTerm}}</div>
<input type="text" ng-model="searchTerm" style="width:400px;"</input><span>  Enter surname or part of surname to search the Active Directory</span>
<br/><br/>
<button ng-click="performSearch()"  class="form-control" style="width:400px;">Search</button>
<br/>
<br/>
<div>   
    <div>{{searchTerm}}</div>
    <table class="table table-bordered table-condensed" style="cell-padding:0px;cell-spaing:0px;font-size:10pt;">
        <thead>
            <tr>
                <th>Name</th>
                <th>Initials</th>
                <th>Title</th>
                <td>Office</td>
                <th>Email</th>
                <th>Company</th>
                <th>Department</th>
                <th>Telephone</th>
                <th>Mobile</th>             
            </tr>           
        </thead>
        <tbody>     
            <tr ng-repeat="people in peopleResults">
                <td>{{people.displayName[0]}}</td>
                <td>{{people.initials[0]}}</td>
                <td>{{people.title[0]}}</td>
                <td>{{people.physicalDeliveryOfficeName[0]}}</td>               
                <td>{{people.mail[0]}}</td>
                <td>{{people.company[0]}}</td>
                <td>{{people.department[0]}}</td>
                <td>{{people.telephoneNumber[0]}}</td>
                <td>{{people.mobile[0]}}</td>
                <td></td>               
            </tr>       
        </tbody>        
    </table>
</div>
</section>

然而,当我开始输入并按下时执行搜索:

$scope.performSearch = function() 
        {
                prPeopleService.findPeople($scope.searchTerm).then(function(people) {
                    $scope.peopleResults = people;
                    $scope.addAlert('success', $scope.peopleResults.length + ' people located');
                },
                function(response) {
                    $scope.addAlert('danger', 'There was an issue trying to look people up from the Active Directory...');
                });
        };

作为参数传入的$ scope.searchTerm是初始的“输入搜索词”...而不是输入到输入字段中的值...它绑定到$ scope.searchTerm ....好像它开始使用副本,然后决定分离自己。

0 个答案:

没有答案