【发布时间】:2017-02-01 22:42:15
【问题描述】:
我能够在 Web 上成功实现 API,如下所示,我在常规 html 文件中有一个按钮...
<div>
<span class="radio-button radio-left" id="sandboxLinkButton">Sandbox Mode</span>
</div>
我包含脚本标签...
<script src="https://cdn.plaid.com/link/stable/link-initialize.js"></script>
我在 html 正文中包含以下 javascript...
<script type="text/javascript">
var sandboxHandler = Plaid.create({
clientName: 'SUM',
env: 'tartan',
product: 'auth',
key: 'test_key',
onSuccess: function(token) {
//window.location = '/accounts.html?public_token=' + token;
console.log("yes");
},
});
// Open the "Institution Select" view using the sandbox Link handler.
document.getElementById('sandboxLinkButton').onclick = function() {
sandboxHandler.open();
};
</script>
现在我想用 Angular js 做同样的事情。我正在使用离子框架(这并不重要)。所以我首先使用以下内容显示必要的html...
app.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/app');
$stateProvider
.state('app', {
url: '/app',
templateUrl: 'templates/menu.html',
controller: 'AppCtrl'
})
});
我的menu.html 文件包含以下按钮...
<span ng-click="create()" class="radio-button radio-left" id="sandboxLinkButton">Sandbox Mode</span>
在ng-click 上,它到达以下控制器。我试图在这个控制器中实现 API 无济于事......
app.controller('AppCtrl', function($scope, $ionicModal, $timeout) {
var sandboxHandler = Plaid.create({
clientName: 'SUM',
env: 'tartan',
product: 'auth',
key: 'test_key',
onSuccess: function(token) {
console.log("yes");
},
});
$scope.create = function() {
sandboxHandler.open();
}
});
我收到错误Plaid 未在控制器中定义。这是为什么呢?
编辑
我使用 Angular 复制了一个 Web 应用程序版本,它工作正常。我使用了以下 CDN 而不是 ionic/angular 一个
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
但我仍然无法让它在我的 ionic web 应用程序上运行。有没有其他人遇到过这个问题?
【问题讨论】:
-
您是否还包括来自 Plaid CDN 的
link-initialize.js? -
@Phil 它包含在我的 html 文件中,所以是的,我想是的
-
哪个 HTML 文件?我不认为它会在你的
menu.html文件中工作,如果它在那里 -
@Phil 对。我把它放在我的
index.html中。附加了menu.html内容的文件。
标签: angularjs ionic-framework plaid