Answer the question
In order to leave comments, you need to log in
Angular ng-click not working?
Hello!
I started learning Angular, I can't figure out why ng-click doesn't work for me from the example, here's the HTML code:
<!DOCTYPE html>
<html lang="ru" ng-app="myApp">
<head>
<meta charset="UTF-8">
<title>Angular JS</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script>
</head>
<body ng-controller="MainController">
Name: <input type="text" ng-model="name"><br />
Hello, {{ name }}!<br />
<input type="button" value="Click" ng-click="myFunc">
<script type="text/javascript" src="/app.js"></script>
</body>
</html>
var app = angular.module("myApp", []);
app.factory('MyLogginService', function(){
return {
log: function(argument){
console.log(argument);
}
};
});
app.factory('AlertLogginService', ['$window', function($window){
return{
log: function(argument){
$window.alert(argument);
}
};
}]);
app.controller('MainController', ['$scope', 'AlertLogginService', function($scope, logger){
$scope.name = "Guest";
$scope.myFunc = function(){
logger.log('hello!');
};
}]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question