我为模块使用2个控制器而感到震惊。我想根据为模块定义的控制器执行单独的操作。我没有得到第二个控制器的预期输出。

请发现以下方法有意义。

var helloApp = angular.module("helloApp", []);
helloApp.controller("CompanyCtrl", function($scope) {
$scope.companies = [
        { 'companyName':'Infi',
            'Level': 1,
            'Created': 'Bangalore','Status': 'In Progress'},
            { 'companyName':'Cogi',
            'Level': 1,
            'Created': 'Bangalore','Status': 'In Progress'},
                { 'companyName':'Infosys Technologies',
            'Level': 1,
            'Created': 'Bangalore','Status': 'In Progress'},
                    { 'companyName':'Infosys Technologies',
            'Level': 1,
            'Created': 'Bangalore','Status': 'In Progress'},
                        { 'companyName':'Infosys Technologies',
            'Level': 1,
            'Created': 'Bangalore','Status': 'In Progress'},
        ];


});

helloApp.controller("SectionController", function($scope) {
$scope.rightsection = [
        { 'Topic':'Bobs Pizza',
            'Comment': 'Raw denim you probably havent heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache ' },
            { 'Topic':'Bill`s Jugs',
            'Comment': 'Raw denim you probably havent heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache '},
                { 'Topic':'Bobs Pizza',
            'Comment': 'Raw denim you probably havent heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache '},
                    { 'Topic':'Bill`s Jugs',
            'Comment': 'Raw denim you probably havent heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache '},
                        { 'Topic':'Bobs Pizza',
            'Comment': 'Raw denim you probably havent heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache '}
        ];

});


当我尝试使用第二个控制器时,(在下面)我看不到页面上显示的任何内容。以上方法是错误的吗?如果是这样,如何将两个控制器添加到单个模块?请帮我。

<div class="right" ng-controller="SectionController">
<table class="table" id="tl" ng-repeat="section in rightSection">
<tr>
<th>Company Name
</th>

</tr>
<tr>
<td>{{section.Topic}}
</td>

</tr>
</table>
</div>

最佳答案

您遍历rightSection且作用域变量为rightsection(区分大小写)。

09-16 23:25