I'm try do make a route using for 2 difference user roles. There 2 UI for each. (I'm using expressjs for server)
For student student-dashboard.html
For teacher teacher-dashboard.html
The route is example.com/dashboard
I try this but it not working:
#Component({
selector: 'app-home-page',
templateUrl: user_type == 1 ?'./teacher-dashboard.html':'./student-dashboard.html'
})
Another ways i think:
1. make 2 angular app( will have 2 dist folder)
2. put 2 UI in 1 file and use ngIf to check.
Which one is a good solution? Many thanks
Related
Let me explain what exactly i am looking for. I have a project where it has quiz type interview and this interview has questions. i have 3 users type and each type has their own questions. A user can have multiple role so for example. if a user choose 2 roles so i need to show them questions for both types.
So here i am using vue js.
I have made a base component called Interview.vue and in this component i am having 3 more child component specifically for those type of users.
Lets say i have 3 types of user - 1) chef 2) waiter 3) barman
So if a user choose role chef and barman so i will render those 2 components which will have questions for that particular roles.
lets say ... my Chef.vue has 2 questions.
and Barman.vue has 3 questions.
So i render these 2 components i will see 5 questions on the web page.
My question is how can i give every question a serial number. ?
You could create a counter that is available globally and increments with every use.
Here's an example implementation:
Vue.prototype.$elNum = 0;
Vue.prototype.$getElNum = () => Vue.prototype.$elNum += 1;
then whenever you are creating an element anywhere in the app, you can set the key or serialNumber by setting it to this.$getElNum()
In my vue application I need an optional router like this
#/profile/(:user/)?task/current-task
Here I want user will be optional. if user not exit then I want to show current login user task.
I know #/profile/(:user/)? it possible. But having children after an optional params not working for me.
any suggestion?
It's possible
You can define #/profile/:user?/task/current-task
Demo
http://jsfiddle.net/29jvk913/
More nested params
http://jsfiddle.net/y3kbovhy/
I am running into this situation (similar to this) when trying to do the following:
Scenario: Create User
Given path 'user'
And request read('user.json');
When method post
Then status 200
And def user_id = response.userId
Scenario: Test A
Given path 'user/' + user_id <- Received javascript error here
...
Scenario: Test B
Given path 'user/' + user_id <- Received javascript error here
...
Scenario: Test A
Given path 'user/' + user_id <- Received javascript error here
...
Basically what i am trying to do is create a user in my database first, then run it through a series of test and use a last scenario to delete this user. Therefore, i need to share the user_id value across multiple scenarios. Background doesn't work for me because that means i have to create a new user for each scenario. I have seen in the demo that a simple way would be to put all test under 1 scenario but i don't feel that it is right to put all tests on 1 scenario
I have reviewed the karate demo but i did not come across any sample code that will help my situation. May i know the right way to do this in Karate? Thanks.
I think you are missing the callonce keyword. Understand it and then look at the demos, for example, this one: callonce.feature.
You will need to move the 'common' code into a separate feature, but that is the right thing to do, because you will typically want it re-usable by multiple feature files as well.
I started using Laravel 3 last week, and then found the new 4 release and I'm trying to convert now.
I have a dozen+ routes that I want to deliver to a specific controller method. i.e., "/api/v1/owners/3/dogs/1 or /api/v1/owners/3" to run "myresourcecontroller#processRequest"
In Laravel 3 I was able to use this: (note * wildcard)
Route::any('api/v1/owners*', 'owners#processRequest'); // Process tags resource endpoints
I found this example from the documentation but it gives me an error. I get a NotFoundHttpException.
//[Pattern Based Filters](http://laravel.com/docs/routing#route-filters)
Route::filter('admin', function()
{
//
});
Route::when('admin/*', 'admin');
Not sure what I'm doing wrong? Is there another way to do this?
I don't want to use the Laravel 4 restful controllers, cause they don't seem to conform to complete restful design. i.e., no verbs in the url.
I have all of my processing written, I just need to be able to route to it.
I need to be able to create new records by POST /api/v1/owners or /api/v1/owners/3/dogs
I cannot use /api/v1/owners/create.
I'm trying to avoid having to write a route for every endpoint, i.e.,
Route::any('api/v1/owners/{owner_id}', 'owners#processRequest');
Route::any('api/v1/owners/{owner_id}/dogs/{dog_id}', 'owners#processRequest');
Thank you for any help
You should make use of resourceful controllers as they're a great asset when building an API. The endpoints you described can be achieved using resource controllers and nested resource controllers.
Route::resource('owners', 'OwnersController');
Route::resource('owners.dogs', 'OwnersDogsController');
Would allow you to create an owner with POST localhost/owners and create a dog on an owner with POST localhost/owners/3/dogs.
You can then wrap these routes in a route group to get the api/v1 prefix.
Route::group(['prefix' => 'api/v1'], function()
{
Route::resource('owners', 'OwnersController');
Route::resource('owners.dogs', 'OwnersDogsController');
});
Haven't used Laravel myself, but try any('api/v1/owners/*', (note slash before asterisk) as in the example.
I have a page_controller with a few actions (dashboard, rules, contact). Each has a corresponding view. I don't know how to route it in Rails 3.
match 'page/:action' => 'page#:action'
The above doesn't work - what I would like is named routes like: page_path(:dashboard) or page_dashboard_path.
Any ideas?
Jacob
You will have to write
get 'page/dashboard'
get 'page/rules'
get 'page/contact'
That will generate the correct named routes.
Note: you can always type rake routes to see which named routes are created.
For more info: see documentation.