컨트롤러에 hello world 함수를 실행하고 싶습니다 (버튼 클릭으로 html에서 호출).하지만 이것을 호출 할 수 없으며 오류를 표시하지 않는 이유가 무엇인지 알 수 없습니다.Angular js에서 html로 함수 컨트롤러를 호출하는 방법은 무엇입니까?
html 코드 :
<html ng-app="app">
<div ng-controller="indexController">
<button type="button" ng-click="helloWorld()">action</button>
</div>
컨트롤러 JS :
(function() {
'use stritct';
angular
.module('app',[])
.controller('indexController', indexController);
indexController.inject = ['$rootScope','$scope'];
function indexController($rootScope,$scope) {
var vm = this;
vm.helloWorld = helloWorld;
function helloWorld() {
console.log('hello');
}
}
})();
당신의 onclick =이 "Helloworld()"를 시도 않았다 대신 HTML 코드에서 =이 "Helloworld를()에"NG 클릭? – AlexWoe89
지시는 ng 클릭이 전형적인 각도이며, –