TypeError:$ scope.scanBarcode不是离子函数

时间:2017-02-27 03:16:37

标签: angularjs ionic-framework ngcordova

我试图在用户点击按钮时显示日志消息。但是这个错误出现了:

protected void grid_RowDataBound(object sender, PX.Web.UI.PXGridRowEventArgs e)
{
    EPApprovalProcess.EPOwned item = e.Row.DataItem as EPApprovalProcess.EPOwned;
    if (item == null) return;
    if (item.Escalated == true)
    {
        //For Row - change the Font to Red
        e.Row.Style.CssClass = "CssEscalated";
    }
    else if (item.CuryTotalAmount.HasValue && item.CuryTotalAmount.Value > 10m)
    {
        //For Row - change the background to Red
        e.Row.Style.CssClass = "CssRowStyle";
    }

    //For Specific Column - change the background to Aqua - Whole Column all row.
    e.Row.Cells["Descr"].Style.CssClass = "CssCellStyle";

    //Conditional a specific column cell
    if (item.CuryTotalAmount.HasValue && item.CuryTotalAmount.Value > 10m)
    {
        e.Row.Cells["CuryTotalAmount"].Style.CssClass = "CssHighlightStyle";
    }
}

这是我的controller.js代码:

TypeError: $scope.scanBarcode is not a function
at new <anonymous> (controllers.js:8)
at Object.instantiate (ionic.bundle.js:18015)
at $controller (ionic.bundle.js:23417)
at Object.self.appendViewElement (ionic.bundle.js:59908)
at Object.render (ionic.bundle.js:57901)
at Object.init (ionic.bundle.js:57821)
at Object.self.render (ionic.bundle.js:59767)
at Object.self.register (ionic.bundle.js:59725)
at updateView (ionic.bundle.js:65400)
at ionic.bundle.js:65377
(anonymous) @ ionic.bundle.js:26799

这是我的HTML代码:

angular.module('app.controllers', [])
.controller('page4Ctrl', ['$scope', '$stateParams', function ($scope, $stateParams) {
$scope.scanBarcode() = function()
{
     console.log("hello");
};

}])

  

可能是什么问题?

1 个答案:

答案 0 :(得分:1)

我认为你已经定义了错误的功能。不要在函数名称()

之后使用scanBarcode

试试这个:

$scope.scanBarcode = function()//no () after the name
{
     console.log("hello");
};