我希望使用Base64编码将用户名和密码发送到服务器。
我发现我可以使用npm导入以下模块:
npm install --save angular-base64
我已检查过,在我的项目文件夹中创建了以下文件夹:node_modules\angular-base64
在我的component.js文件中,我尝试使用以下任意一行代码导入该组件:
import 'angular-base64/angular-base64';
它并没有抱怨导入问题,但是当我尝试使用以下代码时出现了错误:
headers.append('Authorization', 'Basic ' + base64.encode('username:temppass'));
它说:“找不到base64”。
$
,例如$base64.encode('username:temppass')
。 - georgeawg