ng-click不触发

时间:2016-02-14 11:19:32

标签: javascript angularjs

我对angularjs很新,我有以下代码。由于某种原因ng-click没有触发。我见过各种类似的问题,但我没有弄到我在这里做错了什么。控制台上也没有错误。感谢

控制器

.controller("eventsExample", function ($scope) {
        var technologies = [
                { techname: "Angularjs", likes: 0, dislikes: 0 },
                { techname: "Asp.net", likes: 0, dislikes: 0 },
                { techname: "JavaScript", likes: 0, dislikes: 0 },
                { techname: "HTML5/CSS3", likes: 0, dislikes: 0 }
        ];

        $scope.technologies = technologies;

        $scope.inscrementLikes = function (technology) {
            technology.Likes++;
        }

        $scope.inscrementDisLikes = function (technology) {
            technology.Dislikes++;
        }

    })

HTML

<div ng-controller="eventsExample">
    <table>
        <thead>
            <tr>
                <th>Technology</th>
                <th>Likes</th>
                <th>Dislikes</th>
                <th>Hit Like/Dislike</th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="technology in technologies">
                <td> {{technology.techname}} </td>
                <td> {{technology.likes}} </td>
                <td> {{technology.dislikes}} </td>
                <td> 
                    <input type="button" value="Like" ng-click="inscrementLikes(technology)" />
                    <input type="button" value="Dislike"  ng-click="inscrementDisLikes(technology)" />
                </td>
            </tr>
        </tbody>
    </table>
</div>

输出 enter image description here

1 个答案:

答案 0 :(得分:4)

这里有technology.Likes++technology.Dislikes++的拼写错误。

使用小写表示喜欢和不喜欢

示例笔:Sample