Many aquarium plants can also grow emerged like in a paludarium setup with their roots in the water. Aquatic plants use ammonium first for food and if not available will convert nitrate to ammonium. Emerged plants use nitrates for food so you would want to have a pretty stocked tank for enough nitrates depending on what you want to grow. Also adding regular fertilizers for the plants is important.
You'd probably have a better harvest if you skip the fish and add the nutrients and fertilizers directly to the water. You wouldn't have to worry about striking a balance between providing the plants with enough nitrogenous wastes while keeping the tank habitable for the fish.
That said, I've seen it done before. I know a high school science teacher who has a hydroponics system set up with kale growing out of a goldfish tank (he uses the kale to feed his tortoise). Veggies are pretty heavy feeders so selecting fish that produce a lot of waste, such as goldfish, may be a good idea.