Error: Attempt to assign property "template" on null: Attempt to assign property "template" on null