This is the only port to angular that I've seen. The thing is, it is no longer maintained and it doesn't provide a quick getting started tutorial on its read.me in GitHub. I also thought of using hashids.js directly but I am confused with the steps I follow.
So I would like to know if anyone used this on angular and how they did it. Thank you! :)
Update
I've tried importing the said ng port but it gave this error
ERROR in ./node_modules/ng2-hashids/index.ts Module build failed: Error: C:\Users\FireCuda\Projects\angular\InformationAndEve ntSystem\stiGoDashboard\node_modules\ng2-hashids\index.ts is missing from the Ty peScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue In the library repository to alert its author and ask them to package the library using the Angular Package Format. at AngularCompilerPlugin.getCompiledFile (C:\Users\FireCuda\Projects\angular \InformationAndEventSystem\stiGoDashboard\node_modules\@ngtools\webpack\src\angu lar_compiler_plugin.js:740:23) at plugin.done.then (C:\Users\FireCuda\Projects\angular\InformationAndEventS ystem\stiGoDashboard\node_modules\@ngtools\webpack\src\loader.js:41:31) at at process._tickCallback (internal/process/next_tick.js:188:7)
Second update
I tried importing the library directly
import * as hash from '../../../../node_modules/hashids';
and tried this code let id = hash.encode(this.studentDocument.student_id_number); console.log(id);
But it throws this error, sad.
_node_modules_hashids__WEBPACK_IMPORTED_MODULE_2__.encode is not a function
I even tried this
declare var hash:any;
But it throws this error
hash is not defined
It seems that it needs updating before anyone can use this on angular. Any tips on how to use a pure js library, especially this one, would be greatly appreciated!
来源:https://stackoverflow.com/questions/52251613/how-do-i-use-hashids-on-angular