【问题标题】:Why 'ng' attribute not working in HTML tags?为什么 'ng' 属性在 HTML 标签中不起作用?
【发布时间】:2021-11-17 10:22:31
【问题描述】:

我正在用 ASP.NET MVC5 和 Angular JS 编写一个简单的测试应用程序。 我添加了 Angular 脚本,但不知何故 HTML 标记中的“ng”属性不起作用。 例如,在下面的代码中,我想在“ng-click”事件中调用函数“Add()”。这似乎不起作用,因为单击“添加”按钮应该调用了“添加()”函数并清除了用户输入的 UI 字段。

        $scope.Add = function() {
            $http({ method: "POST", data: $scope.Customer, url: "Submit" }).
                success(function (data, status, headers, config) {
                        $scope.Customer =
                        {
                            "CustomerCode": "",
                            "CustomerName": "",
                            "CustomerAmount": "",
                            "CustomerAmountColor": ""
                        };

                    }
            );
        }
<input id="Btn" type="button" value="Add customer" ng-click="Add()" />

【问题讨论】:

    标签: angularjs model-view-controller


    【解决方案1】:

    你是否在你的 HTML 中添加了具有该功能的 js 控制器?

    【讨论】:

    • 是的,它已被添加
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-29
    • 2018-05-05
    • 1970-01-01
    • 2014-05-11
    • 1970-01-01
    • 1970-01-01
    • 2020-01-04
    相关资源
    最近更新 更多