This is exactly what not to do.
Don't ever let your employer know you're unhappy, disloyal, or "looking". This leaves you totally exposed, walking a tightrope without a safety net. You'll piss off your boss for no good reason and only reconfirm your current situation by not already having another offer. If you're so damn good, then why don't you have another offer?
There's a big difference between what should work and what does work. On the job, you and your employer are teammates. When it comes to your renumeration, you are adversaries. Don't ever forget that.
It's healthy for both sides. You get a better job and a bit of self-satisfied pleasure during the "no, you lost me" speech. They get to understand why they lost a good worker, and the real costs associated with it. With luck, the team you left behind will have a better environment, since just maybe management will learn something.