استفاده از مسیرهای مطلق در حین import ماژولها در برنامههای مبتنی بر TypeScript
نویسنده: وحید نصیری
تاریخ: ۱۳۹۶/۱۲/۰۷ ۲۰:۲۰
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
import { SpecialCollection } from "../../special";
import { LoginComponent } from "../login";
import { TextUtils } from ".../../utils/text";
import { Router } from "../../../core/router"; import { Data } from '../data'; import { Data } from '../../../data';
import { BrowserStorageService } from "./../../core/browser-storage.service"; {
"compilerOptions": {
"baseUrl": "src",
"paths": {
"@app/*": [
"app/*"
],
"@app/core/*": [
"app/core/*"
],
"@app/shared/*": [
"app/shared/*"
],
"@env/*": [
"environments/*"
]
}
}
} import { BrowserStorageService } from "@app/core/browser-storage.service"; import { BrowserStorageService } from "./../../core/browser-storage.service";
import { Component } from '@angular/core'; "paths": {
"@angular/*": ["node_modules/@angular/*"]
}, resolve: {
extensions: ['*', '.js', '.ts'],
modules: [
rootDir,
path.join(rootDir, 'node_modules')
],
alias: {
'@app': 'src/app'
}
}, import { BrowserStorageService } from "./../../core/browser-storage.service"; import { BrowserStorageService } from "@app/core/browser-storage.service"; import { BrowserStorageService } from "@app/core"; export * from "./browser-storage.service"; export * from "./app-config.service"; export * from "./seo-service";
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"@app/core/*": [ "app/core/*" ],
}
}
} export * from './utilities/DateTime'
import { DateTime } from '@app/common' import { DateTime } from './utilities/DateTime' ng new angular-apps --create-application=false
ng generate application cac-web
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"@app/*": [
"app/*"
],
"@app/core/*": [
"app/core/*"
],
"@app/shared/*": [
"app/shared/*"
],
"@env/*": [
"environments/*"
]
}
}
} |node_modules |projects--------------cac-web|e2e-----------------|src | | |protractor.conf.js | | |tsconfig.json | |src-----------------|app-----------------|client(Module) | | | |shared(Module) | | | |core(Module) | | | |app-routing.module.ts | | | |app.component.html | | | |app.component.ts | | | |app.module.ts | | |assets | | |environments | | |index.html | | |main.ts | | |polyfills.ts | | |styles.css | | |test.ts | |browserslist | |karma.conf.js | |tsconfig.app.json | |tsconfig.spec.json | |tslint.json |.editorconfig |.gitignore |angular.json |package-lock.json |package.json |README.md |tsconfig.json |tslint.json
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@app/*": [
"projects/cac-web/src/app/*"
],
"@app/core/*": [
"projects/cac-web/src/app/core/*"
],
"@app/shared/*": [
"projects/cac-web/src/app/shared/*"
],
"@env/*": [
"projects/cac-web/src/environments/*"
]
}
}
}
export * from './services/alertify.service';
بعد از فراخوانی سرویس در یک کامپوننت دیگر این نتیجه حاصل میشود :
و آدرس مطلق بجای @app با .. شروع میشود.