Where to add ng-click code


#1

I am using angular and I have a button called register in the html file (register.html)
Register

I have a register.js file like this

class RegisterCtrl {
constructor($scope, $reactive) {
‘ngInject’;

$reactive(this).attach($scope);

this.helpers({})
}

export default angular.module(‘register’, [
angularMeteor
])
.component(‘register’, {
templateUrl: ‘imports/components/register.html’,
controller: RegisterCtrl
});


 }

when I write code within this.helpers my code is executed when page is loaded itself. I understand that is the default behavior. I want to execute the method only when the button is actually clicked.
so I wrote
register.controller(‘RegisterCtrl’,function($scope){
$scope.registerUser = function() {
console.log(“inside sign up”);
Meteor.call(‘registerUser’,user);
};

export default angular.module(‘register’, [
angularMeteor
])…

can anyone please share , how to wire button click, and where to write within the component file

Thanks,


#2

I figured it out.

The code should be within constructor:
constructor($scope, $reactive) {
‘ngInject’;

$reactive(this).attach($scope);

$scope. registerUser = function() {
console.log(“inside sign up”);
Meteor.call(‘registerUser’,user);