Mechanism for reaction of NOCl (Tilden reagent) with primary amines
Why would the chloride ion attack the electron rich amine? The amine is the best nucleophile is the system and will attack the NO+. This gives a RNH-NO nitroso species which is then protonated on Oxygen, loses water and gives the diazonium cation. This adds loses nitrogen rapidly and adds Chloride to give the primary alkyl chloride. 

More can be read about this process here (which I where I sourced the reaction scheme) or by searching the term "nitrosation of primary amine"