我一直在寻找一种优化图像以获得更好性能的解决方案。
在尝试了一些解决方案(例如Sharp和imagemin,这导致文件永远不会更小,有时更大)之后,我现在正在尝试尝试 Google 的 pagespeed。不幸的是,pagespeed 似乎只支持 Apache 和 Nginx,我不想将其添加到我的堆栈中只是为了图像优化(另外,我更喜欢在上传时进行优化,而不是在服务器请求时进行优化,即使缓存)。
我将非常感谢任何可能帮助我在本机 Node.js 中实现这一点的信息,以及任何其他(有效!)图像优化建议。
javascript image-compression image-optimization pagespeed node.js
使用jquery-select2(不是 ui-select)和angular,我试图将值设置为ng-model.
我已经尝试使用$watch和ng-change,但似乎没有与选择2选择一个项目后开火.
不幸的是,我使用的是购买的模板,不能使用angular-ui.
HTML:
<input type="hidden" class="form-control select2remote input-medium"
ng-model="contact.person.id"
value="{{ contact.person.id }}"
data-display-value="{{ contact.person.name }}"
data-remote-search-url="api_post_person_search"
data-remote-load-url="api_get_person"
ng-change="updatePerson(contact, contact.person)">
Run Code Online (Sandbox Code Playgroud)
ClientController:
$scope.updatePerson = function (contact, person) {
console.log('ng change');
console.log(contact);
console.log(person);
} // not firing
$scope.$watch("client", function () {
console.log($scope.client);
}, true); // not firing either
Run Code Online (Sandbox Code Playgroud)
JQuery集成:
var handleSelect2RemoteSelection = function () {
if ($().select2) {
var $elements = $('input[type=hidden].select2remote');
$elements.each(function(){
var $this = $(this);
if ($this.data('remote-search-url') && $this.data('remote-load-url')) {
$this.select2({
placeholder: …Run Code Online (Sandbox Code Playgroud) angularjs jquery-select2 angularjs-ng-change jquery-select2-3