Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs TypeError:$scope.scanBarcode不是ionic中的函数_Angularjs_Ionic Framework_Ngcordova - Fatal编程技术网

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");
};