exc-core-v2
v1.0.6
Published
ExcCoreModule implements some static core features for the app and the communication between components, directives, services etc.
Downloads
2
Readme
Module Exc-Core-V2
ExcCoreModule implements some static core features for the app and the communication between components, directives, services etc.
##Install To install ExcRestModule into your project use
npm i exc-core-v2
Usage
ExcCoreModule can be used everywhere in your application. There is no need to import it as dependeny in your app.module. In every Module, Component, Directive or service you can import it an can use it as a static class.
Example
import {ExcCoreModule} from 'exc-core-v2';
Members
Array
Methods
|Method|Return|Description| | --- | --- | --- | | Get(array,value)|any|Gets the first entry from array matches to value| | GetIndex(array,value)|number|Gets the index of the first entry from array matches to value| | GetObject(array, key, value)|any|Gets the first entry from array of objects where the object[key] matches to value| | GetObjectIndex(array, key, value)|number|Gets the index of the first entry from array of objects where the object[key] matches to value| | GetAll(array, key, value)|any[]|Gets all entries from array of objects where the object[key] matches to value| | Remove(array, value)|any[]|Removes the first element from the array matches to the value. Returns remaining array items| | RemoveObject(array, key, value)|any[]|Removes the first element from the array matches to the value. Returns remaining array items| | RemoveAll(array, value)|any[]|Removes all elements from the array matches to the value. Returns remaining array items| | RemoveObjectAll(array, key, value)|any[]|Removes all elements from the array matches to the value. Returns remaining array items| | Add(array, value)|any[]|Adds an element to the array. Returns result array| | Merge(array1, array2)|any[]|Adds all elementes of array2 to array1. Returns merged array| | Exists(array, value)|boolean|Search an array for an element matches to the value. Returns true or false| | ExistsObject(array, key, value)|boolean|Search an array for an element where the object[key] matches to the value. Returns true or false| | Distinct(array)|any[]|Removes duplicated items in array.| | ExistsObject(array, key)|any[]|Removes duplicated items in array where the object[key] matches.|
Guid
Methods
|Method|Return|Description| | --- | --- | --- | |NewGuid()|string|Generates a new uniqueidentifier (Guid)|
Object
Methods
|Method|Return|Description| | --- | --- | --- | |Replace(destination,source)|void|Replaces all values in destination object from source object.Keeps values in destination if they doesn't exist in sourceIgnores values from source if they doesn't exist in destination| |Merge(destination,...source)|void|Merges values from all source objects to destination object| |DeepMerge(destination,...source)|void|Merges (recursive) values from all source objects to destination object|
String
Methods
|Method|Return|Description|
| --- | --- | --- |
|Format(text,...args)|string|Formats a string and injects the arguments by indexExampleExcCoreModule.String.Format("This {0} is crazy for {1}!","world","Robin")
returns "This world is crazy for Robin!"|
|Reverse(text)|string|Reverses a given string|
Methods
|Method|Return|Description|
| --- | --- | --- |
|on(name,callback)|function|Registers a callback function to a specified name as an event|
|call(name,...args)|function|Calls all callback functions for the specified name and tunnels all arguments to callback functions.|
|showInfo(message,title?)|void|Calls "eAM.ShowInfo" event. Listening to this event with ExcCoreModule.on("eAM.ShowInfo",function(message,title){//Your code here});
|
|showSuccess(message,title?)|void|Calls "eAM.ShowSuccess" event. Listening to this event with ExcCoreModule.on("eAM.ShowSuccess",function(message,title){//Your code here});
|
|showWarning(message,title?)|void|Calls "eAM.ShowWarning" event. Listening to this event with ExcCoreModule.on("eAM.ShowWarning",function(message,title){//Your code here});
|
|showError(message,title?)|void|Calls "eAM.ShowError" event. Listening to this event with ExcCoreModule.on("eAM.ShowError []() ",function(message,title){//Your code here});
|
|showModal(content,header?,size?,data?,closeViaOverlay?,footerButtons?)|Observable|Open a modal window as configured. Place content as string or place a component name|
|RegisterService(key,value)|void|Registers a value to ExcCoreModule.Services().|
|RegisterConfig(key,value)|void|Registers a value to ExcCoreModule.Config().|
|Services()|any|Gets all values registered by RegisterService(key,value)|
|Config()|any|Gets all values registered by RegisterConfig(key,value)|
Class ExcTranslation
ExcTranslation is a class for translation of text resources. All other classes using translation have to extend this class
Example
export class ClassName extends ExcTranslation {}
After this you have the option to use translations in ClassName
####Dependencies If you want to use ExcTranslation class you have to register a TranslateService into ExcCoreModule.
You can add exc-rest-v2
as package and use ExcTranslateService
for that.
Details for adding and implementation are in readme of exc-rest-v2 package description.
Methods
|Method|Return|Description| | --- | --- | --- | |getCurrentLang()|string|Get current selected language as string| |onLangChange|Observable|Define a callback function which is called at language change| |getResource(name,param?)|string|Get a text resource of the current ClassName and the selected language. You can use placeholders in translation file to pass params to specific positions| |getRessource(name,param?)|string|(deprecated) Get a text resource of the current ClassName and the selected language. You can use placeholders in translation file to pass params to specific positions| |getGlobal(name,param?)|string|Get a global text resource and the selected language. You can use placeholders in translation file to pass params to specific positions| |getTranslation(name,param?)|string|Get text resource from root position and the selected language. You can use placeholders in translation file to pass params to specific positions|