我试图通过写一些字段来检查我的表单是否正在编辑.我读过$ dirty应该为这个任务工作,但我无法弄清楚我在这里缺少什么:
<!DOCTYPE html>
<html lang="en">
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="formCtrl">
<form name = "myForm" novalidate>
First Name:<br>
<input type="text" ng-model="user.firstName"><br>
Last Name:<br>
<input type="text" ng-model="user.lastName">
<br><br>
<button ng-click="reset()">RESET</button>
</form>
<p> is Form dirty? {{isDirty}}<p>
<p>form = {{user }}</p>
<p>master = {{master}}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('formCtrl', function($scope) {
$scope.master = {firstName:"John", lastName:"Doe"};
$scope.reset = function() {
$scope.user = angular.copy($scope.master);
};
$scope.reset();
$scope.isDirty = $scope.myForm.$dirty;
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我试图在用户修改表单时将标志isDirty设为true.谢谢
我是角度js的新手,我希望在按下按钮后在浏览器的新窗口中打开PDF文档.
我$http.get()在前端发出GET请求,在后端有一个Java休息服务,它响应GET并生成PDF.我希望在浏览器上打开这个PDF.
如果无法以这种方式打开PDF,那么至少用AngularJs打开任何PDF,我该怎么做?
@GET
@Path("/printPdf")
public Response printService(){
//generates the pdf
File reportFile = new File(filePath);
String name = reportName + "." + "pdf";
ResponseBuilder response = Response.ok(new TemporaryFileInputStream(reportFile));
response.header("Content-Disposition", "attachment; filename=" + name);
response.header("Content-Type", "application/pdf");
response.header("Access-Control-Expose-Headers", "x-filename");
response.header("x-filename", name);
return response.build();
}
Run Code Online (Sandbox Code Playgroud)
这就是后端在休息服务中生成响应的内容.
我想在加/减绿色/红色按钮中添加工具提示,请参阅 此示例。我怎样才能做到这一点?
angularjs ×2
javascript ×2
browser ×1
datatables ×1
form-editing ×1
forms ×1
get ×1
html ×1
http ×1
pdf ×1
tooltip ×1