Angularjs TypeError:$scope.scanBarcode不是ionic中的函数
我试图在用户单击按钮时显示日志消息。但是,这个错误却出现了:Angularjs TypeError:$scope.scanBarcode不是ionic中的函数,angularjs,ionic-framework,ngcordova,Angularjs,Ionic Framework,Ngcordova,我试图在用户单击按钮时显示日志消息。但是,这个错误却出现了: 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.bu
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代码:
<ion-view title="Page1" id="page18">
<ion-content padding="true" class="has-header">
<button id="page4-button4" class="button button-positive button-block" ng-click="scanBarcode()">Scan</button>
<button id="page4-button5" class="button button-positive button-block">Display Scanned Data</button>
扫描
显示扫描数据
可能是什么问题?我认为您定义的函数是错误的。不要在函数名后使用
()
,即scanBarcode
试试这个:
$scope.scanBarcode = function()//no () after the name
{
console.log("hello");
};
您应该在离子内容中定义控制器。我想<代码>谢谢,错误仍然会显示出来。。
$scope.scanBarcode = function()//no () after the name
{
console.log("hello");
};