0

I am using Angular 1.4.8 I was having a list in controller. It is connected to a module. and referring it in my html doesn't show list of activities

folder structure: 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>

app/controllers/app.js

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

app/controllers/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);

Getting output as:

Filter it on: textbox shows here.

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

Here instead of showing 2 rows, it just displays as {{}} for all the paramaters.

please help me know the issue. Thanks in Advance!!

1
  • My Array is : $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'}]; Commented Dec 26, 2015 at 13:34

1 Answer 1

2

Remove the bad token in the array:

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

Codepen working: http://codepen.io/armellajuan/pen/admKOv

Sign up to request clarification or add additional context in comments.

5 Comments

If you are using chrome maybe is usefull to check the console for this type of errors. Just hit f12 and go to "console".
Sorry its my mistake. for simplicity, i have removed few entries while keeping in here. I dont that any bad characters in my code.
With you new array is working: codepen.io/armellajuan/pen/xZEpBG or i didn't undestand the problem.
No its not working. Thanks for your response. I will try with f12 though.
Maybe is a script problem. Check the console. Maybe you see an include problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.