Angular 4 – Failed: Can’t resolve all parameters for ActivatedRoute: (?, ?, ?, ?, ?, ?, ?, ?)

You want to inject a fake ActivatedRoute to your component, since you create it yourself in the test, and the router thus doesn’t create it for you and inject an ActivatedRoute. So you can use something like this: describe(‘SomeComponent’, () => { const fakeActivatedRoute = { snapshot: { data: { … } } } as … Read more

Redirect user with router depending on logged in status

Here are 3 ways to do what you asked, from least preferred to favorite: Option 1. Imperatively redirect the user in AppComponent @Component({ selector: ‘app-root’, template: `…` }) export class AppComponent { constructor(authService: AuthService, router: Router) { if (authService.isLoggedIn()) { router.navigate([‘dashboard’]); } } } Not very good. It’s better to keep the “login required” information … Read more

Ruby on rails: singular resource and form_for

Unfortunately, this is a bug. You’ll have to set the url like you mention. = form_for @order, :url => order_path do |f| Note that this will properly route to create or update depending on whether @order is persisted. Update There’s another option now. You can add this to your routes config: resolve(“Order”) { [:order] } … Read more

Angular2 Router error: cannot find primary outlet to load ‘HomePage’

Although @JS_astronauts already provided a solution, I think it would be instructive to explain the error… The primary outlet is set when Angular parses an HTML template and finds directive RouterOutlet, i.e., when it finds RouterOutlet’s selector: <router-outlet></router-outlet>. Although your template does contain <router-outlet></router-outlet>, your component does not contain directives: [ROUTER_DIRECTIVES], so Angular won’t look … Read more

How to separate routes on Node.js and Express 4?

Server.js var express = require(‘express’); var app = express(); app.use(express.static(‘public’)); //Routes app.use(require(‘./routes’)); //http://127.0.0.1:8000/ http://127.0.0.1:8000/about //app.use(“/user”,require(‘./routes’)); //http://127.0.0.1:8000/user http://127.0.0.1:8000/user/about var server = app.listen(8000, function () { var host = server.address().address var port = server.address().port console.log(“Example app listening at http://%s:%s”, host, port) }) routes.js var express = require(‘express’); var router = express.Router(); //Middle ware that is specific to … Read more

SSH -L connection successful, but localhost port forwarding not working “channel 3: open failed: connect failed: Connection refused”

ssh -v -L 8783:localhost:8783 myacct@server.com … channel 3: open failed: connect failed: Connection refused When you connect to port 8783 on your local system, that connection is tunneled through your ssh link to the ssh server on server.com. From there, the ssh server makes TCP connection to localhost port 8783 and relays data between the … Read more