Angularjs 按钮分配给控制器中的作用域变量并用表达式绑定到html现在我正在单击按钮未调用函数,如何才能做到这一点?

Angularjs 按钮分配给控制器中的作用域变量并用表达式绑定到html现在我正在单击按钮未调用函数,如何才能做到这一点?,angularjs,Angularjs,scope.html=“{data}}”。此处{{data}}表达式不工作,单击按钮时getUserDetails函数不调用。我该怎么做?请帮帮我 我试过密码 html ---- <div ng-controller="MyCtrl"> <form> <input type="text" ng-model="user.name" /> <input type="button" ng-

scope.html=“{data}}”。此处{{data}}表达式不工作,单击按钮时getUserDetails函数不调用。我该怎么做?请帮帮我

我试过密码

    html
    ----
    <div ng-controller="MyCtrl">
      <form>
         <input type="text" ng-model="user.name" />
         <input type="button" ng-click="sayName(user.name);" value="sayName"/>
      </form>
       <span ng-bind-html-unsafe="html"></span>
    </div>

    script
    -----
    var myApp = angular.module('myApp',[]);
    function MyCtrl($scope) {
     $scope.sayName = function(data){
     $scope.html = "<div><button ng-click='getUserDetails('"+data+")'> {{data}}</button></div>";
     }
     $scope.getUserDetails = function(data){
     alert(data)
     }
   }
html
----
剧本
-----
var myApp=angular.module('myApp',[]);
函数MyCtrl($scope){
$scope.sayName=函数(数据){

$scope.html=“这就是您想要做的吗?请参阅更新的fiddle

html
----
{{name}}
剧本
-----
var myApp=angular.module('myApp',[]);
函数MyCtrl($scope){
$scope.data=[];
$scope.sayName=函数(数据){
$scope.data.push(数据);
}
$scope.getUserDetails=函数(数据){
警报(数据)
}
}

hellow任何人请帮助我输入框输入名称,如“clickme1”提交的按钮输出我看到的是clickme1按钮。接下来我输入的输入像'clickme2'单击的sayname按钮现在我看到的是大纲像'clickme2'按钮,但我没有看到第一个'clickme1'单击我按钮,用户输入的多少次按钮需要可见。我怎么做请帮助我?请帮助我garethb?{name}我一直在我的实践项目中。在brower Inspet中,我看到了这样的代码为什么?这只是角度。我认为如果你要尝试使用它,你需要更好地理解角度。这个网站对于刚开始的人来说非常好,请帮助我garethb
html
----
<div ng-controller="MyCtrl">
  <form>
     <input type="text" ng-model="user.name" />
     <input type="button" ng-click="sayName(user.name);" value="sayName"/>
  </form>
   <div ng-repeat="name in data track by $index"><button ng-show="name.length > 0" ng-click='getUserDetails(name)'> {{name}}</button>
</div>

script
-----
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
 $scope.data=[];
 $scope.sayName = function(data){
 $scope.data.push(data);
 }
 $scope.getUserDetails = function(data){
 alert(data)
 }
}