我正在使用Angular5和angular service worker.
我cached有些数据和一些资产,一切都按预期工作正常,甚至部署了代码.
现在,如果我更新一些代码并再次部署,则service worker不会更新.
所以,我已经通过Angular服务工作者链接和我已经实现了SwUpdate service.
这是我的代码:
我创建了一个服务并在App Component中调用它
import { Injectable, NgZone } from '@angular/core';
import { interval } from 'rxjs/observable/interval';
import { SwUpdate } from '@angular/service-worker';
import { Observable } from 'rxjs/Rx';
@Injectable()
export class ServiceWorkerService {
constructor(updates: SwUpdate, ngZone: NgZone) {
console.log('Servicee worker update called');
updates.available.subscribe(event => {
console.log('current version is', event.current);
console.log('available version is', event.available);
updates.activateUpdate().then(() => document.location.reload());
});
updates.activated.subscribe(event => { …Run Code Online (Sandbox Code Playgroud) def delete_users
users = User.active.where(:id=>params[:users])
users.each do |user|
array = []
if user.active?
array << user
end
end
if (array.count > 0)
user.update_attributes(:status => "inactive")
else
"I want an alert/popup here saying no users, when 'delete_users' is called and the condition comes here."
........ do other stuff ......
end
end
Run Code Online (Sandbox Code Playgroud)
结束
在一个控制器中,我有这个方法,ajax调用将进入这个方法,当条件来到其他时,我需要一个警告/弹出窗口说没有用户在那里删除,然后我可以更新一些其他的东西.
提前致谢.
我有一个组件及其 HTML 文件。
成分:
hello-world.component.ts
import {Component} from 'angular2/core';
@Component({
selector: 'hello-world',
templateUrl: 'hello-world.html'
})
export class HelloWorld {
yourName: string = '';
}
Run Code Online (Sandbox Code Playgroud)
模板:
你好-world.html:
<label>Name:</label>
<h1>Hello {{yourName}}!</h1>
Run Code Online (Sandbox Code Playgroud)
现在,我有其他template.html没有组件的html ,例如它包含,
模板.html
<h1>Welcome to template file</h1>
<p> This is an example file </p>
Run Code Online (Sandbox Code Playgroud)
现在,我想将template.html文件包含在hello-world.html. 我怎样才能做到这一点。
在 Angular1 我曾经做过,
<div ng-include src="'template.html'"></div>
Run Code Online (Sandbox Code Playgroud)
我怎样才能在 Angular2 中做到这一点?我对 Angular2 很陌生。
我在很多地方搜索了这个问题,每个人都给出了一个有组件的答案。但没有得到我需要的解决方案。
我想问一下我是否应该在我的控制器中保留空方法(这是一个关于代码风格的问题):
before_action :set_project, only: [:show,:new]
def show
end
def new
end
Run Code Online (Sandbox Code Playgroud)
我应该保持这样或简单地删除节目和新动作
class ProjectController < ApplicationController
before_action :set_project
def index
#indexaction
end
def create
#createaction
end
Run Code Online (Sandbox Code Playgroud)
是否更加偏执?Rails Styleguide并不表示任何溶剂,只有:
def show
end
Run Code Online (Sandbox Code Playgroud)
比...更好
def show; end
Run Code Online (Sandbox Code Playgroud) 我正在使用sequelize js和开发一个node js application,将其部署到生产环境并具有实时数据库。
而在发展模式下,如果我需要alter的DB,我以前用做它Sequelize.sync({ force: true })和它的工作好。
但是现在,开发完成后,我想更改表并向其中添加列。
我搜索了许多帖子,但没有获得有关如何运行这些迁移的确切示例。
我尝试使用Umzug并运行迁移,但是这使我出错。
这是我尝试的代码,
migrations / barmigration.js:
var Sequelize = require('sequelize');
"use strict";
module.exports = {
up: function(migration, DataTypes) {
return [
migration.addColumn(
'Bars',
'PrinterId',
Sequelize.STRING
),
migration.addColumn(
'Bars',
'PrinterStatus',
Sequelize.STRING
)]
},
down: function(migration, DataTypes) {
return
[
migration.removeColumn('Bars', 'PrinterStatus'),
migration.removeColumn('Bars', 'PrinterId')
]
}
};
Run Code Online (Sandbox Code Playgroud)
这是umzug configuration:
var Umzug = require('umzug');
var sequelize = require('sequelize');
var …Run Code Online (Sandbox Code Playgroud) angular ×2
caching ×1
firefox ×1
html ×1
javascript ×1
node.js ×1
ruby ×1
sequelize.js ×1
umzug ×1