下面的代码插入somestring到文件中,但也将替换文件中的文本.怎么解决这个问题?
fd = fs.openSync('file', 'r+')
buf = new Buffer('somestring')
fs.writeSync(fd, buf, 0, buf.length, 0)
fs.close(fd)
Run Code Online (Sandbox Code Playgroud) 我按照add-custom-header-to-your-file创建了我自己的自定义标题插件.当我保存文件时,它将自动.将当前日期时间更新为Last-Modified字段.但是这将添加编辑历史记录以撤消列表.如何禁用撤消临时?
我正在从教程EggHead angular.element学习并遵循它来创建测试脚本.但是我的angular.element的行为与教程不同.toggleClass或addClass将"class"添加到"input"和"div".见下面的剧本和图片.这是一个错误吗?或者我错过了什么?
<html ng-app="app">
<head lang="en">
<meta charset="utf-8" />
<title>Debug</title>
<link rel="stylesheet" href="/css/foundation.css" />
</head>
<body>
<dumb-password></dumb-password>
<script src="/js/angular-1.2.0rc1/angular.js"></script>
<script>
angular.module('app', [])
.directive('dumbPassword', function () {
return {
restrict: 'E',
replace: true,
template: '<div><input type="text" ng-model="model.input"><div>{{model.input}}</div></div>',
link: function (scope, element) {
scope.$watch('model.input', function (value) {
if (value === 'password') {
element.children(1).toggleClass('alert-box alert')
} else {
element.children(1).removeClass('alert-box alert')
}
})
}
}
})
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
