Just a few things to note.
1. It's a loaded chamber indicator (LCI), not a cocking indicator. It's important because the barrel has a square notch for the LCI arm, not the "peep hole" style like the others. Your barrel should fit but the "holes" won't match. While the ability to check if a round is in the chamber may be reduced, I think this is more of a "cosmetic" issue.
2. Just to make sure you're aware, that's a completely stripped slide so you'll need a few other parts. My suggestion is to buy them and install them in the new slide rather than swap them from your old one. That way you lessen the risk of buggering your original slide and make it way easier to swap back and forth whenever you want.
As Storminorman said, as long as you're M&P is a 2.0 it should drop right it.