【发布时间】:2017-02-19 15:22:14
【问题描述】:
我正在努力将图像放入 JSON 对象中,这被证明是一个真正的痛苦。虽然我可以让图像显示在网站的登录页面上(base 64 代码是正确的),但我想做的是显示一个对象的属性,包括带有ui-view 的图像。
JSON
{
"FullName": "Lucy Ann Johnson",
"WentMissing": "1961",
"Age:": "20",
"Description": "Short brunette, was last seen wearing a green dress.",
"Image:" <img src="data:image/gif;base64,">
}
索引
<div class="container"
style="
margin-top:0px width=100%" ui-view>
</div>
控制器
/*globals angular, console, $http, data, ListingsController*/
var mymodule = angular.module("controllers", []);
mymodule.controller("HomeController", function ($scope) {console.log("HomeController"); });
mymodule.controller("AboutController", function ($scope) {console.log("AboutController"); });
mymodule.controller("ListingsController", function ($scope, $http) {var data = $http.get("js/data.json"); });
mymodule.controller("ContactController", function ($scope) {console.log("ContactController"); });
mymodule.controller("ReportController", function ($scope) {console.log("ReportController"); });
app.js
/*global angular*/
angular.module('app', ['ui.router', 'controllers'])
.config(function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/home');
$stateProvider
.state('home', {
url: '/home',
templateUrl: 'templates/home.html',
controller: 'HomeController'
})
.state('about', {
url: '/about',
templateUrl: 'templates/about.html',
controller: 'AboutController'
})
.state('listings', {
url: '/listings',
templateUrl: 'templates/Listings.html',
controller: 'ListingsController'
})
.state('contact', {
url: '/contact',
templateUrl: 'templates/Contact.html',
controller: 'ContactController'
})
.state('report', {
url: '/report',
templateUrl: 'templates/Report.html',
controller: 'ReportController'
});
});
【问题讨论】:
标签: angularjs json image object base64