I am learning Angular 2 and I am using angular-cli to generate components and services. I am using the directory structure proposed by angular-cli (see screenshot below). I need to add some domain model object (e.g. User, Profile, etc.), but I don't know where to put them.
What is the recommended location for those objects in the directory structure?
You will want to have your app-wide models stored at the root level (default: src/app) except that those values should be in the shared directory (src/app/shared).
If you generate those models with the CLI (from the project root directory) you will run:
ng generate class shared/profile model
which will yield:
src/app/shared/profile.model.ts
src/app/shared/profile.model.spec.ts
and also add a reference to the profile exports to the index.ts within the shared directory, so you can reference them (from the root component)
import { Profile } from './shared';
If the domain model classes are used by all the components, it can be put in a model.ts file within shared folder.
Related
I am using alanning:roles and have put my users in admin groups successfully in my server - main file. However now I'm trying to add Meteor.users.allow() to my admin in order to allow them to delete other users. I'm having trouble finding an example of the right location within my code to put this. Do I put it in the server main under startup? or in a separate users collection (I'm using React)?
I think this is illustrating a blindspot in my understanding of meteor or react so if you're feeling instructive, please help me out :) Thanks!
If you are working with Meteor more recent than 1.3.0, you can place your hooks/allows/methods files anywhere under a server subdirectory, as long as you import (as in the ES6 module import) them. It's helpful to have them separated logically.
Here is a sample directory structure we're using in our project:
public/ (static files, assets)
settings/ (to be loaded as command-line args for different environments)
test/
imports/
client/
startup/
components/
views/
server/
startup/
allows/
hooks/
methods/
publications/
both/
utils/
collections/ (collections are here, because they're shared)
Now, to be honest, this is an older project, so React was not considered here, but this could still be helpful for you when you're organizing your imports. Obviously, you're going to need a couple of entry files for your client and server that import all of the necessary dependencies.
From then on, for example, in your imports/server/allows/<collection_name>.js file, you place your allows like:
import { SomeCollection } from '/imports/both/collections/someCollection.js';
SomeCollection.allow({
insert: function () {
return true;
},
update: function () {
return true;
},
remove: function () {
return true;
}
});
I prefer using absolute file path imports in Meteor projects, since there the root path resolves to the root of your project. Makes them easier to copy-paste.
Hope that helps.
I am using sencha cmd 6 for building my application.
my folder structure is
classic
src
model
view
account
jobs
portal
portal.js
controller
store
production build process execution is successful but when i load that build its giving .js file not found error.
So i include all js files in folder structure into main js portal.js then .js error is removed and build works.
But i dont want to include all these list of files in one single js, so can we skip the js include part from portal.js and use any property or attribute to include all js files ?
You can specify with * like 'Ext.chart.*' in requires section of Ext.app.Application.
Hope this helps.
In the Grails 3.2.3 documentation, it shows this piece of code as an example of a custom script:
def scriptName = args[0]
def model = model(scriptName)
def overwrite = flag('force') ? true : false
render template: template('artifacts/Script.groovy'),
destination: file("src/main/scripts/${model.lowerCaseName}.groovy"),
model: model,
overwrite: overwrite
Where is the artifacts directory in the grails-app or src hierarchies?
For the example you cite, the artifacts directory is in the profile's jar file.
(the relevant source is: https://github.com/grails-profiles/base/tree/master/templates)
In general any profile or plugin that has a templates directory, it will be found in the jar for the profile or the plugin.
But your project can override anything from a profile or a plugin. You follow the same pattern for the different kinds of templates rooted in your project at src/main/templates.
For example, if you say
grails install-templates
A directory src/main/templates/scaffolding will be created containing copies of the templates applied by the scaffolding plugin that you can edit to customize how scaffolding views, generated controllers and so on, render.
For script templates, the path is artifacts not scaffolding, so if you have a script template or a domain class template you like better than the default one, you would put it in
src/main/templates/artifacts
I am using angular-cli, it suppose to create a component with a sub folder called shared with index.ts, but I am not seeing that.
This was taken out with the addition of NgModule as of rc5. The need to nest components inside of shared directories is against the pattern of declaring them within a given module.
I am new to Go and AppEngine. I am trying to figure out how to create packages but I keep running into conflicts. My directory structure is below:
GOPATH
third-party-libs
app
app.yaml
controllers
default.go -- package controllers
models
models.go -- package models
templates
templates.go -- package templates
I am importing the templates package as follows import ("app/templates") inside default.go
When I do goapp serve I get this error:
Failed parsing input: app file templates.go conflicts with
same file imported from GOPATH
I have tried a bunch of things and nothing has worked so far. These are things I have tried:
Changed the templates directory to apptemplates and the corresponding file to apptemplates.go, changed package name to apptemplates. I imported it as app/apptemplates
I tried different combinations by changing the file name but not the package name, vice versa, etc. Either it does not find the file or has a conflict.
I am importing html/template in my templates.go file. So I commented out the entire file just keeping the package declaration but did not make the conflict go away
I thought may be another file is named templates.go but when I do this (at the GOPATH level) find . -name "*.go" | grep "templates.go" I only see the one file I have created.
I am confused as to how packages are created. I have changed the name to something generic so it does not look like a naming issue. Can someone please tell me how I can debug this error?
Thanks!
Rename the package to a non-conflicting name as in #1. Import the package using the path "apptemplates".
Packages inside of the application directory (the directory containing app.yaml) are imported with a path relative to the application directory. See Organizing Go Apps for the complete details.