Cook the pasta according to package instructions in a large pot of salted boiling water until al dente. Reserve 1/2 cup of pasta water, then drain the pasta and set aside.
In a large skillet, heat the olive oil over medium heat. Add the sliced onions and salt, stirring occasionally. Cook for about 15-20 minutes until the onions are golden brown and caramelized.
Sprinkle the sugar over the onions and continue to cook for another 5 minutes, stirring frequently. Add the minced garlic and red pepper flakes, cooking for an additional 2 minutes until fragrant.
Add the cooked pasta to the skillet with the caramelized onions. Pour in the reserved pasta water a little at a time, tossing to combine until the pasta is well coated and heated through.
Remove from heat and stir in the grated Parmesan cheese. Adjust seasoning if necessary.
Serve the pasta hot, garnished with fresh parsley and a drizzle of chilli oil.