将输入文本数据发送到div的内容

时间:2017-01-29 18:01:36

标签: angularjs binding

html代码

<div style="position: absolute; bottom: 0px; width: 100%">
<div style="text-align: center">
<div>
   {{great}}
</div>
<form>
   <div class="list">
      <div class="list list-inset">
         <label class="item item-input">
         <input type="text" class="form-control input-lg" height="20" placeholder="Add Note" ng-model="searchText">
         </label>
         <button class="button button-block"  ng-click="addTag()">Add Note</button>
      </div>
   </div>
</form>

app.js

$scope.searchText ="  ";
$scope.great = "Note Here";
$scope.addTag = function () {
    $scope.great == $scope.searchText;   
};

我正在尝试为我创建的任务添加注释。这是我的应用程序:

https://behrouz2000.fwd.wf

当您单击任务并单击一个笔记时,它应该以一个分钟时间戳创建一个在彼此之上的笔记。

1 个答案:

答案 0 :(得分:1)

分配时,应使用相同的

 $scope.great = $scope.searchText;

<强>样本

var app = angular.module("myApp", []);
 app.controller("myCtrl", ['$scope', function($scope) {

   $scope.searchText ="Note Here";
    $scope.great = [];
    $scope.addTag = function () {
        $scope.great = $scope.searchText;
    };
 }]);
<!DOCTYPE html>
<html ng-app="myApp">
<head>
  <meta charset="utf-8" />
  <script src="https://code.angularjs.org/1.4.7/angular.js"></script>
</head>
<body ng-controller="myCtrl">
  <div style="position: absolute; bottom: 0px; width: 100%">
    <div style="text-align: center">
       <div>
            {{great}}
       </div>
       <div class="list">
         <div class="list list-inset">
         <label class="item item-input">
         <input type="text" class="form-control input-lg" height="20" placeholder="Add Note" ng-model="searchText">
         </label>
         <button class="button button-block"  ng-click="addTag()">Add Note</button>
         </div>
         </div>
      </div>
    </div>
    </body>
</html>