我的NodeJS-Server接收到base64编码的图片.
data:image/jpeg;base64,/9j/4QCcRXhpZgAASUkqAAgAAAA ... CiiigD//Z
Run Code Online (Sandbox Code Playgroud)
收到的数据应保存为jpg.因此我使用Buffer和FileSystemWriter:
var imageBuffer = new Buffer(data, 'base64'); //console = <Buffer 75 ab 5a 8a ...
fs.writeFile("test.jpg", imageBuffer, function(err) { //... });
Run Code Online (Sandbox Code Playgroud)
fs.writeFile不会调用错误.保存了jpeg文件,但我无法打开它.Image-Viewer说:
File is damaged or too big.
Run Code Online (Sandbox Code Playgroud)
原始文件大6kb,新文件7kb.
如何使用ng-click而不是应用ui-sref的链接来更改route.state.
我试过这个:
<button ng-click="selectDir(file.fullPath)">set</button>
Run Code Online (Sandbox Code Playgroud)
同
$scope.selectDir = function(location) {
options.storageLocation = location;
$route.current = 'recorder.options';
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用.有任何想法吗?
我有一个工厂来执行get请求,我想测试一下.不幸的是,业力测试告诉我$ httpBackend没有定义响应.
AngularJs 1.2.14,Jasmine 2.0,Karma 0.12.0
这是我要测试的模块:
var appFactory = angular.module('appFactory', []);
appFactory.factory('boxListService', function($http){
return{
getList: function(){
return $http.get('/boxlist').then(function(result){
return result.data;
});
}
};
});
Run Code Online (Sandbox Code Playgroud)
我的测试是这样的:
describe('Module-Test', function() {
beforeEach(module('appFactory'));
it('should call $http.get in getList', inject(function (boxListService, $httpBackend){
$httpBackend.expectGET('/boxlist');
boxListService.getList();
$httpBackend.flush();
}));
});
Run Code Online (Sandbox Code Playgroud)
信息:
Error: No response defined !
at $httpBackend (D:/nodeJS/host/test_app/src/public/js/libs/angular/angular-mock.js:1206:13)
Run Code Online (Sandbox Code Playgroud) 是否有可能使用express作为客户端模块,向另一台服务器发出http请求?
目前我以这种方式提出要求:
var req = http.get({host, path}, function(res) {
res.on('data', function(chunk) {
....
}
}
Run Code Online (Sandbox Code Playgroud)
这太笨重了.Express作为服务器模块使用起来非常舒服.我想有一种简单的方法可以通过使用express来获取请求.我不喜欢快递api,我在那里找不到任何东西.
如果我将一个插件添加到config.xml并上传我的项目,则配置似乎格式不正确.
<?xml version='1.0' encoding='utf-8'?>
<widget
id="com.example.app"
version="0.0.1"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0"
>
<name>App</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Me
</author>
<content src="index.html" />
<access origin="*" />
<preference name="phonegap-version" value="3.0.0" />
<gap:plugin name="org.apache.cordova.file" />
</widget>
Run Code Online (Sandbox Code Playgroud)
phonegap 说明告诉我将此行添加到我的config.xml中:
<gap:plugin name="org.apache.cordova.file" />
Run Code Online (Sandbox Code Playgroud)
每次我尝试上传它都会变得格格不入.
我想观看一个对象/数组,可以通过服务或控制器例程进行编辑.我以为Observable可以观看一个对象/数组.
我的实现不会对项目的更改做出反应:
private data : Observable<Array<any>>;
private dataObserver: Observer<Array<any>>;
private sub : Subscription;
private items: <Array<any>>;
ngOnInit() {
this.items = itemService.getItems();
this.data = new Observable<Array<any>>(observer =>{
this.dataObserver = observer;
});
this.data.subscribe(
x => console.log('onNext: %s', x),
e => console.log('onError: %s', e),
() => console.log('onCompleted')
);
this.dataObserver.next(this.items);
}
private start(){
//change values of the array in an interval
let loop = Observable.interval(250)
let i=0;
self.sub = loop.subscribe(() => {
if(self.items[0]){
self.items[0].id= i;
if(i<100) i++;
else i=1;
}
})
}
Run Code Online (Sandbox Code Playgroud)
subsvaltion subsciption不会对items数组的更改做出反应.它只会在下一个mehtod上触发.另一方面..这对于简单的手表方法来说太麻烦了. …
我想改变激活元素的CSS样式.
这是你可以看到的离子列表.
我试着像这样设置aktivated元素的css样式:
.item-content.activated{
background-color: rgba(0,100,255, 0.5);
}
Run Code Online (Sandbox Code Playgroud)
这不会改变任何事情
在离子的css框架中我有这一行设置激活元素的样式:
.item.active, .item.activated, .item-complex.active .item-content, .item-complex.activated .item-content, .item .item-content.active, .item .item-content.activated
{
border-color: #ccc;
background-color: #D9D9D9;
}
Run Code Online (Sandbox Code Playgroud)
如果我在框架中更改它,它的工作原理.但我只希望它应用于列表项和我自己的css样式表......我该怎么做?
我在离子框架项目中有一些嵌套在列表中的textareas.textarea没有完整显示.它的一部分是在屏幕外.
<div class="list" style="width:100%;">
<label class="item item-input" style="max-width:100%">
<span class=input-label>Description</span>
<textarea required></textarea>
</label>
</div>
Run Code Online (Sandbox Code Playgroud)
会发生什么是textarea的宽度变得太大,span.width + textarea.width> 100%.
如果我手动将textarea宽度设置为一点,则显示为100%.
我将它的父级的最大宽度设置为100%,所以它不应该变大,但确实如此.
如何防止此行为并让textarea不会在屏幕上生长.

是否可以使用angular file upload插件将文件作为八位字节流上传?我手动将标题中的内容类型设置为"application/octet-stream",但上传者不验证它自己的标题.
正文总是形式数据:
------WebKitFormBoundaryGgizqnvAqFRXn2HB
Content-Disposition: form-data; name="file"; filename="53f60e5267c2460000623dcd.wav"
Content-Type: audio/wav
------WebKitFormBoundaryGgizqnvAqFRXn2HB--
Run Code Online (Sandbox Code Playgroud)
是否有可能将上传设置为八位字节流?我上传到的服务器不支持表单数据.
我正在使用Select.AsyncCreatable:
<Select.AsyncCreatable
clearableValue={true}
multi={true}
scrollMenuIntoView={true}
name="field-name"
value={values}
loadOptions={this.getOptions}
onChange={value => {
this.handleOnChange(value...)
}}
placeholder={this.defaultPlaceholder}
/>
Run Code Online (Sandbox Code Playgroud)
如何编辑我创建的选项.我可以删除已创建的选项并重新输入它们,但是是否可以选择编辑选定的值?它会更舒服.
angularjs ×3
css ×2
node.js ×2
angular ×1
angular-ui ×1
cordova ×1
css3 ×1
express ×1
html5 ×1
jasmine ×1
javascript ×1
karma-runner ×1
react-select ×1
reactjs ×1
typescript ×1