【发布时间】:2015-10-12 04:16:38
【问题描述】:
我对一个模块使用 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 上调用 ng-repeat
标签: javascript jquery angularjs angular-ui-bootstrap