Angular Js中的显示图像不起作用? [英] Display Image In Angular Js is Not working?
本文介绍了Angular Js中的显示图像不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< button class = btn btn-default id = < span class =code-string> dLabel type = button data- toggle = 下拉列表 aria-haspopup = true aria-expanded = false > {{Roles}}
< img src = images / user-pic.png ng-attr-src = {{'images /'+ profilepic}} alt = 用户 >
< / 按钮 >
和我的Js代码一样这样
$ scope.init = function(){
// 检查是否在url中有查询
// 并在其值不为空的情况下触发搜索
$ http.get( api / Login / Getusername)
.success(函数(数据,状态,标题,配置){
if (data!= ){
debugger;
$ scope.Employees = data;
$ scope.User = data [0] .username;
$ scope.Roles = data [0] .RoleName;
$ scope.profilepic = data [0] .profilepic;
$ scope.LoginTime = data [0] .SessionInTime;
}
else if (data === null | data == ){
window .location.href = 登录;
}
});
};
我想在Image COntrol显示图像
解决方案
scope.init = function(){
// 检查url中是否有查询
// 并在其值不是的情况下触发搜索空
http.get( api / Login / Getusername )
.success(函数(数据,状态,标题,配置){
if (data!= ){
debugger;
scope.Employees =数据;
Hi,
<button class="btn btn-default" id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{Roles}}
<img src="images/user-pic.png" ng-attr-src="{{'images/'+profilepic}}" alt="user">
</button>
And My Js Code Like This
$scope.init = function () {
// check if there is query in url
// and fire search in case its value is not empty
$http.get("api/Login/Getusername")
.success(function (data, status, headers, config) {
if (data != "") {
debugger;
$scope.Employees = data;
$scope.User = data[0].username;
$scope.Roles = data[0].RoleName;
$scope.profilepic = data[0].profilepic;
$scope.LoginTime = data[0].SessionInTime;
}
else if (data === null | data == "") {
window.location.href = "Login";
}
});
};
I want to Display Image at Image COntrol
解决方案
scope.init = function () { // check if there is query in url // and fire search in case its value is not empty
http.get("api/Login/Getusername") .success(function (data, status, headers, config) { if (data != "") { debugger;
scope.Employees = data;
这篇关于Angular Js中的显示图像不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文