我的代碼運行良好,直到我在兩個單詞之間使用空格爲止。 我正在使用AngularJs。
stringAmi = '<i class="fa fa-user-plus fa-2x" ng-click="demandeAmiNotif(' + $scope.invite + ');"></i>';
$ scope.invite是我喜歡保持用戶的名稱字符串:「雨果」 我有這樣的錯誤:
Error: [$parse:syntax] Syntax Error: Token 'Hugo' is unexpected, expecting [)] at column 22 of the expression [demandeAmi(Victor Hugo);] starting at [Hugo);].
你仍然需要產生有效的JS。 –
因此,所執行的代碼行是'demandeAmiNotif(Victor Hugo);'是的,這是一個語法錯誤。 – David
但它與demandeAmiNotif(Victor)合作;我的意思是當$ scope.invite =「Victor」; – DionysoSong