0
我想在ASP.NET MVC应用程序中设置AngularJS中的openrainbow API。有两种方式可以配置和使用openrain API连接。 With AngularJS和Without AngularJS无法加载* .json文件:(提供404文件未找到)
我已经在没有AngularJS的情况下对它进行了配置,它的工作完美。但我想配置它并与AngularJS连接。
下面给出的是我从API Documentation使用的代码。
AngularJS控制器
var sample = angular.module('sample', ['sdk']);
sample.controller("sampleController", [
"rainbowSDK",
function(sdk) {
"use strict";
var onReady = function onReady() {
console.log("[DEMO] :: Rainbow SDK is ready!");
};
var onLoaded = function onLoaded() {
console.log("[DEMO] :: Rainbow SDK has been loaded!");
sdk.initialize().then(function() {
console.log("[DEMO] :: Rainbow SDK is initialized!");
}).catch(function() {
console.log("[DEMO] :: Something went wrong with the SDK...");
});
};
$rootScope.$on(sdk.RAINBOW_ONREADY, onReady);
$rootScope.$on(sdk.RAINBOW_ONLOADED, onLoaded);
}
]);
HTML视图
<!DOCTYPE html>
<html ng-controller="sampleController">
<head>
<title>OpenRainbow API</title>
</head>
<body>
<script src="//api.openrainbow.com/sdk/web/libs/loader-sdk.min.js" data-main="./config.json"></script>
</body>
</html>
config.json文件
{
"libraries": {
"prerequisites": [
"//code.jquery.com/jquery-2.1.3.min.js",
"//cdn.jsdelivr.net/momentjs/2.15.1/moment-with-locales.min.js",
"//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.7/angular.min.js"
],
"sdk": {
"official": [
"//api.openrainbow.com/sdk/web/libs/vendors-sdk.min.js",
"//api.openrainbow.com/sdk/web/libs/rainbow-sdk.min.js"
],
"default": "official"
},
"after": [
]
},
"app": {
"bootstrap": "sample",
"key": {
"appID":"",
"appSecret":""
},
"js": [
"./src/js/sdkSampleApp.js",
"./src/js/components/connection/connectionCmp.js"
],
"css": [
"src/styles/sdkSampleApp.css",
"src/js/components/connection/connectionCmp.css"
]
},
"settings": {
"verboseLog": true,
"disableCache": true,
"enableLoader": true
}
}
控制台输出:
的数据主要属性未加载从路径的config.json文件。该文件存在于该路径中时,该文件的路径是正确的。