Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Miloš Lapiš
@mlc-mlapis
@Aishasadat123 Then fs.readFileSync would be necessary or placing writing into the body of that async.
Aishasadat123
@Aishasadat123
my final code
it shows an error that facilities in 15 is not define
let data = JSON.stringify(facilities);
Miloš Lapiš
@mlc-mlapis
@Aishasadat123 It can't work correctly because you have fs.writeFileSync outside of the async body.
@Aishasadat123 Sure because the declaration of facilities is inside the async block.
fs.readFile('facilities.json', (err, data) => {
    if (err) throw err;

    const facilities = JSON.parse(data); // Your code line
    for (let i = 0; i < facilities.length; i++) {
        const facility = facilities[i];
        if (!facility.Type) {
            // The element doesn't contain property of Type
            facility.Type = 'NPM';
        } else {
            console.log('... data type:', typeof facility.Type); // Would be a string data type
        }
    }
    console.log(facilities);

    const outputData = JSON.stringify(facilities);
    fs.writeFileSync('facility-2.json', outputData);
});
Aishasadat123
@Aishasadat123
now it shows this error
SyntaxError: Identifier 'data' has already been declared
Miloš Lapiš
@mlc-mlapis
@Aishasadat123 Sure, use outputData.
Aishasadat123
@Aishasadat123
ok
@mlc-mlapis it find the facility with type NPM
it just find thefacility with NPM type not add anything
Miloš Lapiš
@mlc-mlapis
@Aishasadat123 Try facility['Type'] = 'NPM'; instead of facility.Type = 'NPM';
Aishasadat123
@Aishasadat123
not working
the result is same
Miloš Lapiš
@mlc-mlapis
@Aishasadat123 Add:
if (!facility.Type) {
   // The element doesn't contain property of Type
   facility.Type = 'NPM';
   console.log('... adding Type property:', facility);
} else {
   console.log('... data type:', typeof facility.Type); // Would be a string data type
}
Aishasadat123
@Aishasadat123
@mlc-mlapis still same result
Miloš Lapiš
@mlc-mlapis
@Aishasadat123 What is shown on the console for facility then?
Aishasadat123
@Aishasadat123
it show all facilities with type property
it does not make any change in the facility which does not has type property
Miloš Lapiš
@mlc-mlapis
@Aishasadat123 I mean the result of: console.log('... adding Type property:', facility);
Aishasadat123
@Aishasadat123
... data type: string
... adding Type property
Miloš Lapiš
@mlc-mlapis
@Aishasadat123 Nothing for both syntax: facility.Type = 'NPM'; or facility['Type'] = 'NPM';?
Aishasadat123
@Aishasadat123
it show this
for both show same result
Miloš Lapiš
@mlc-mlapis
@Aishasadat123 console.log('... adding Type property:', facility); shows only ... adding Type property: and nothing for facility?
@Aishasadat123 Then print also:
const facility = facilities[i];
console.log('... original content:', facility);
Aishasadat123
@Aishasadat123
it show facilities
Miloš Lapiš
@mlc-mlapis
@Aishasadat123 And after adding facility['Type'] = 'NPM'; it shows nothing?
Aishasadat123
@Aishasadat123
when i run the it also shows the facilities
i think i made you confused
can you please run it on your pc ?
if you want i will send the json file
ok?
Miloš Lapiš
@mlc-mlapis
OK. I can do it later. So put that JSON example here.
Aishasadat123
@Aishasadat123
ok
can i send in private message ?
santoshfurtado
@santoshfurtado

Hi Guys,

Could you please help me on the angular SSR with base ref deployment issue?
I am able to load the application without SSR with base ref but I am getting below issue with SSR & base href

Error : Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec

I have also tried setting the type to type="text/javascript" but it also throws Unexpected token <

01.png
02.png
Ashref
@Asher2016
hello , i have issue when router.navigate(['../']) doesn't work because i have object/iframe loading html page
so this the code
@Component 
turnBack(){
      this.router.navigate(['../'], {relativeTo: this.activatedRouter})
    }

@HTML
<object [data]="urlSafe" type="text/html"
        width="800" height="1200" typemustmatch>
</object>
WahidN
@WahidN
How can I intercept a route change?
jyoti singh
@jyotisingh144

I need to change parent's components heading as per child Component's heading through router outlet. How can I do that?

Sample structure
in parent Component.ts
title = ""

In parent Component.html
{{title}}

<router-outlet></router-outlet>

in child component.ts
title = "Login"

I want to get this child's component title in parent component

Ashref
@Asher2016
Guys , any advice how to add param to route when it change or leave the actual component ?
StephenS
@S-Stephen
Hi Everyone, I'm considering configuring a multi-project repo. I realise that the nx tools exist but wandered how far I can get with the standard angular-cli setup. Indeed I would rather not have to really on a further tool beyond angular cli. I've read that Angular CLI supports multi project repos :https://angular.io/guide/file-structure#multiple-projects. However I'm after information of how to configure build and test of these atomically (along with how to transition from a traditional angular CLI repo). I was wandering whether any of you friendly folk may have written an article on this (accessible if not registered on medium) or indeed have any tips?
Miloš Lapiš
@mlc-mlapis
@S-Stephen Most of such projects probably used Nx monorepo, which extended the original base used in CLI and add many new features.
StephenS
@S-Stephen
Thanks @mlc-mlapis any idea what the 'road map' is for Nx. Will I at some stage need a license etc?