I have defined the following alias in
alias fg='find . -name $1 | xargs grep --color $2'
in order to write
fg "*.txt" " my_text "
and find all file that have extension .txt and contain " my_text " but it does not work. Why?
Aliases in bash do not take parameters (as already pointed out), so when you need something like that you can use bash functions (like the one provided by @l0b0).
But what you are trying to achieve here, can be done in a better way by using only grep.
EDIT: in a function