Just like this, I want to add an element<p class='main'></p> in html after pressing enter. How should I write the following if? There is another question. How does angularjs operate the DOM? I just started learning it and I don’t quite understand it.
var app = angular.module('myApp',[])
.controller('todoCtrl',function ($scope) {
$scope.enterEvent = function(e) {
var keycode = window.event?e.keyCode:e.which;
if(keycode==13){
}
}
});
Data-driven model.
You need to change your thinking about operating dom.
What do you want to do after entering? You need an extra dom. Assuming that the previous dom number is 0, then if you press Enter, it will be +1.
Then it’s easy. You first define a variable. Whether the variable is initialized to 1 or 10,000 depends on your mood.
You can put this
<p class='main'></p>
先写在页面上,写在todoCtrl
in. Then add the ngShow syntax to the element to control the hiding and display of the element at any time: