javascript - AngularJS 问题不显示输出

标签 javascript angularjs

我使用的是 Angular 1.4.8 我在 Controller 中有一个列表。它连接到一个模块。 在我的 html 中引用它不会显示事件列表

文件夹结构:app/sorting.html

<!Doctype html>
<html ng-app="demoApp">
<body ng-controller="MyC">

    <div>
    Filter it on: <input type="text" ng-model="filteron.aname" />
    <table>
    <TR>
        <TD>Activity Id </TD>   
        <TD> Sbprocess Name </TD>   
        <TD> Activity Name </TD>  
        <TD> Cost </TD>
    </TR>
        <TR ng-repeat="activity in activities | filter:filteron">
            <TD>{{activity.activityid}}</TD>
            <TD>{{activity.aname}}</TD>
            <TD>{{activity.subprocess}}</TD>
            <TD>{{activity.cost | currency:'Rs. '}}</TD>
        </TR>
    </table>
        </div>
        <script src="angular.js"></script>
            <script src="controllers/app.js"></script>
        <script src="controllers/mycontroller.js"></script>
</body>
</html>

应用程序/ Controller /app.js

var demoApp = angular.module('demoApp', []);

应用程序/ Controller /mycontroller.js

    var MyC = function ($scope) {
        $scope.activities = [{aname: 'First', subprocess: 'Product', activityid: '500', cost: '2001'},
        {aname: 'Second', subprocess: 'Program', activityid: '501', cost: '1500'},
        {aname: 'Third', subprocess: 'Engineeding', activityid: '502', cost: '5999'},
        {aname: 'Fourth', subprocess: 'Resource', activityid: '503', cost: '999'},
        {aname: 'Fifth', subprocess: 'FM', activityid: '504', cost: '1765'}];

};

    angular.module('demoApp')
        .controller('MyC', MyC);

获取输出为:

Filter it on: textbox shows here.

Activity Id Sbprocess Name  Activity Name   Cost
{{activity.activityid}} {{activity.aname}}  {{activity.subprocess}}         {{activity.cost | currency:'Rs. '}}

这里没有显示 2 行,而是仅将所有参数显示为 {{}}。

请帮我了解一下这个问题。提前致谢!!

最佳答案

删除数组中的坏标记:

 $scope.activities = [{aname: 'First', subprocess: 'Product', activityid:     '500', cost: '2001'},
    {aname: 'Second', subprocess: 'Program', activityid: '501', cost: '1500'},
        }/*<-----remove this*/ ];
};

Codepen 工作: http://codepen.io/armellajuan/pen/admKOv

关于javascript - AngularJS 问题不显示输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34471729/

相关文章:

javascript - js-csp Operations.mult 不会跨 channel 分配值

javascript - 刷新所有窗口中的所有选项卡

javascript - 以复杂的方式在 3 个集合之间创建多对多关系

angularjs - java.io.IOException : Unable to unwrap data, 无效状态

AngularJS 双向绑定(bind)表达式与转换器(类似过滤器)

javascript - 初始窗口大小/调整大小捕获

javascript - Socket.io 在第二个窗口上重复发出

javascript - Nativescript Angular TabStrip可见性设置为折叠仍然占用空间

javascript - 在字符串末尾的第 3 个字符前添加一个空格

angularjs - 如何将AngularJS ui-grid单元格中的数字值格式化为两位小数?