2
这是我的代码,同时输入到文本框,但仅在按下button.Please帮我之后,我想值angularjs点击按钮之后,从文本框获取值仅
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
<script>
var myApp = angular.module('myApp', []);
myApp.controller('myController', function ($scope) {
$scope.getName = function() {
$scope.name = fname;
$scope.lastName = lastName;
};
})
</script>
</head>
<body ng-app="myApp" >
<div >
<input type="text" ng-model="name"/> <br>
<input type="text" ng-model="lastName" />
</div>
<div ng-controller="myController">
<input type="button" value="click" ng-click="getName()" />
<br>
Hello FirstName {{name}}<br>
Last Name {{lastName}}
</div>
</body>
</html>
值都来了。
我尝试了两种方式简单以及使用服务或工厂方法,但没有成功
你好,先生..谢谢你的回答 – ishan
因为我是新的请指导我如何使用服务或工厂达到同样的东西 – ishan
好吧我会更新答案,请不要忘记标记为正确的答案 – webmaster