我正在使用node.js,尝试保存文件,不会抛出任何错误,是的,图像将无法保存.这是我保存文件的方式:
var url = 'captures/' + getFileName() + '.png';
fs.writeFile(url, base64, 'base64', function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
Run Code Online (Sandbox Code Playgroud)
有助手为我创建文件名:
function getFileName(){
var d = new Date()
return d.getMonth()+'-'+d.getDate()+'-'+d.getYear()+'-'+d.getHours()+'-'+d.getMinutes()+d.getSeconds();
}
Run Code Online (Sandbox Code Playgroud)
有人有这个问题吗?
我正在尝试为我的应用创建一个"喜欢"的功能.我希望能够将动态生成的数字的值设置为"like count".问题在于使用'ng-init',因为文档说这是一个不好的方法!
如何在"控制器"中设置值而不是"视图"?
这是我到目前为止:
<!doctype html>
<html ng-app="plunker" >
<head>
<meta charset="utf-8">
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<article ng-repeat="feed in feeds">
<h3>{{feed.createdby}}</h3>
<p>{{feed.content}}</p>
<button ng-click="likeClicked($index)">{{isLiked[$index]|liked}}</button>
<span ng-init="likeCount=feed.likes.length">{{likeCount}}</span>
</article>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
谢谢,
J.P
我花了很多时间研究在本地运行的文件上使用GA的方法,但没有使用http://localhost:(some_port).
我使用的每个方法都不会返回任何常规数据.这是我最接近的东西:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-47519364-1']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', 'true']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/u/ga_debug.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Run Code Online (Sandbox Code Playgroud)
以前有人以这种方式工作吗?
我正在努力Masonry作为一个Angular指令工作,虽然我在以下代码中遇到以下问题,但该指令部分在线记录:
HTML代码:
<div ng-controller="GridCtrl" class="grid-wrapper">
<div class="masonry">
<div ng-repeat="item in gridItems" ng-class="item.class">
<h3>{{item.name}}</h3>
<img ng-src="{{item.image}}"/>
<br>
<button ng-repeat="button in item.buttons">{{button.text}}</button>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
角度指令代码:
'use strict';
angular.module('HomeCourtArenaApp').directive('masonry', function ($parse) {
return {
restrict: 'AC',
link: function (scope, elem, attrs) {
elem.masonry({ itemSelector: '.masonry-item', columnWidth: $parse(attrs.masonry)(scope) });
}
};
});
angular.module('HomeCourtArenaApp').directive('masonryItem', function () {
return {
restrict: 'AC',
link: function (scope, elem, attrs) {
elem.imagesLoaded(function () {
elem.parents('.masonry').masonry('reload');
});
}
};
});
Run Code Online (Sandbox Code Playgroud)
SCSS代码:
.grid-wrapper {
position: absolute;
top: 0; …Run Code Online (Sandbox Code Playgroud) 我似乎无法使用控制器来设置div的CSS背景属性.到目前为止,这是我的代码,根据文档:
HTML:
<div class="hero" ng-controller="HeroCtrl" ng-style="heroImage"></div>
Run Code Online (Sandbox Code Playgroud)
JS:
'use strict';
angular.module('AppliedSiteApp').controller('HeroCtrl', function ($scope) {
$scope.heroImage = {
background: 'images/brick.jpg'
};
console.log($scope.heroImage);
});
Run Code Online (Sandbox Code Playgroud)
CSS:
.hero {
width: 100%;
min-height: 350px;
background-position: center center;
}
Run Code Online (Sandbox Code Playgroud)
我也尝试在这里用小提琴复制这个设置.有没有人有任何想法?
我试图获取元素的宽度,但该值始终小于实际宽度。到目前为止,这是我的代码:
this.rightSectionElement = this.$('.sections').eq(1).get(0);
this.rightSectionOffset = this.rightSectionElement.getBoundingClientRect().width;
Run Code Online (Sandbox Code Playgroud)
相关元素的 CSS 是这样的:
nav{
position: relative;
width: 100%;
height: 100%;
@include inline-flex();
flex-wrap: nowrap;
justify-content: space-between;
z-index: 1;
.sections{
@include flex-value(0 1 auto);
height: 100%;
width: auto;
display: block;
...
Run Code Online (Sandbox Code Playgroud)
这种方法对于 flexbox 排列的元素来说不是很好吗?
我有一个似乎行为不端的控制器.我已经删除了所有其他有效的代码:
控制器:
'use strict';
angular.module('AppliedSiteApp').controller('CarouselCtrl', function ($scope) {
$scope.nextImage = function() {
console.log('hi');
}
});
Run Code Online (Sandbox Code Playgroud)
视图:
<div class="carousel" ng-controller="CarouselCtrl">
<ul class="nav">
<li ng-click="prevImage()"><</li>
<li ng-click="nextImage()">></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
每次我点击浏览器中的按钮时都会显示:'TypeError:object is not function'或'no method replace'.我究竟做错了什么?
我目前正在构建标题图像的幻灯片,然后单击选择并设置该标题图像以替换旧标题图像.到目前为止这是我的代码:
var app = angular.module('plunker', []);
app.controller('BannerCtrl', function($scope) {
var imageCounter = 0;
$scope.nextButton = function () {
imageCounter = imageCounter + 1;
if (imageCounter === 1) {
$scope.carouselState = 'second-slide';
}
if (imageCounter === 2) {
$scope.carouselState = 'third-slide';
}
if (imageCounter > 2) {
imageCounter = 0;
$scope.carouselState = 'reset-slide';
}
};
$scope.previousButton = function () {
imageCounter = imageCounter - 1;
if (imageCounter < 0) {
imageCounter = 2;
$scope.carouselState = 'third-slide';
}
if (imageCounter === 1) …Run Code Online (Sandbox Code Playgroud) 如何在Grunt文件中添加一行/ s以确保它找到部分视图?
我的grunt.js文件是你用Yeoman搭建AngularJS应用程序,没有插件或JQuery,只是Angular时提供的vanilla.