gpt4 book ai didi

javascript - 使用Angular.js,网页不显示提交的数据

转载 作者:行者123 更新时间:2023-12-03 08:33:26 25 4
gpt4 key购买 nike

var app=angular.module('chirpApp',[]);

app.controller('mainController',function($scope){
$scope.posts=[];
$scope.newPost={created_by:'', text:'', created_at:''};

$scope.post=function(){
$scope.newPost.created_at = Date.now();
$scope.posts.push($scope.newPost);
$scope.newPost={created_by:'', text:'', created_at:''};
}
});
<!DOCTYPE html>

<html>
<head>
<title>Chirp</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
<script src="javascripts/chirpApp.js"></script>
</head>
<body>
<div id='main' ng-controller="mainController">
<form ng-Submit="post()">
<input required type="text" placeholder="Your name" ng-model="newPost.created_by"/>
<textarea required maxlength="300" rows="3" placeholder="say something" ng-model="newPost.text" ></textarea>
<input class="button" type="submit" value="Chirp!"/>
</form>
<div id="post-stream">
<h4>Chirp Feed</h4>
<!-- to be polulated by angular-->
<div class='post' ng-repeat="post in posts | orderBy:'created_at':true" ng-class-odd="'odd'" ng-class-even="'even'">

<p>{{post.created_by}} says {{post.text}} at {{post.created_at}}</p>

</div>
</div>
</div>
</body>
</html>

我正在跟踪 MEAN 堆栈图,但无法显示表单提交的名称和文本。我是网络开发新手,不知道为什么它不起作用

最佳答案

您好,您可以尝试添加这个

<html ng-app="chirpApp">

关于javascript - 使用Angular.js,网页不显示提交的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33270593/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com