小编Arv*_*aha的帖子

如果原始不存在,angularjs将显示默认图像

如果图像存在,我想显示用户图像,如:

<img alt="user_image" src="/images/profile_images/{{result.image}}">
Run Code Online (Sandbox Code Playgroud)

如果用户图像不可用,则应显示默认图像,Like

<img alt="user_image" src="/images/default_user.jpg">
Run Code Online (Sandbox Code Playgroud)

我怎么能通过html页面中的angularjs来做到这一点?

angularjs

20
推荐指数
4
解决办法
3万
查看次数

Angularjs我可以从另一个控制器更改控制器的$ scope值吗?

我有一个HTML div,就像

<div id="loader-container" data-ng-controller="LoaderController" ng-show="shouldShow">
Some html design
</div>
Run Code Online (Sandbox Code Playgroud)

在我的控制器

angular.module('core').controller('LoaderController', ['$scope','$location', 'Authentication', '$rootScope',
function($scope,$location, Authentication, $rootScope) {
    $scope.shouldShow = true;
}
Run Code Online (Sandbox Code Playgroud)

]);

而现在,我想隐藏另一个控制器的html div,这就是为什么我试图将另一个控制器的$ scope.shouldShow变量设为false.那我怎么做

$scope.shouldShow = false;
Run Code Online (Sandbox Code Playgroud)

从另一个控制器.有可能或任何其他方式.?

javascript angularjs

5
推荐指数
2
解决办法
1万
查看次数

如何修复ESLint错误使用数组解构

我的代码中有一行:

this.someVar = document.querySelectorAll("div[container-type='some-container']")[0];
Run Code Online (Sandbox Code Playgroud)

ESLint检查为此行“使用数组解构”抛出错误。如何解决此错误。

javascript eslint

3
推荐指数
1
解决办法
832
查看次数

mysql计数不能与join和where子句一起使用

如果我使用此查询:

SELECT clinic.id
FROM clinic 
JOIN dentist ON dentist.id = clinic.dentist_id 
JOIN user ON user.id = dentist.user_id 
WHERE user.status = 'Active'
AND clinic.status = 'Approved'
AND user.role_id = 2
GROUP BY clinic.id;
Run Code Online (Sandbox Code Playgroud)

所以它给了我所有的行

32
35
36
42
44
47
50
Run Code Online (Sandbox Code Playgroud)

错误如果我要获得结果的总数,那么我应用查询:

SELECT count(clinic.id) AS cnt
FROM clinic 
JOIN dentist ON dentist.id = clinic.dentist_id 
JOIN user ON user.id = dentist.user_id 
WHERE user.status = 'Active'
AND clinic.status = 'Approved'
AND user.role_id = 2
GROUP BY clinic.id;
Run Code Online (Sandbox Code Playgroud)

我刚刚将count()应用于id,然后返回

1
1
1
1
1 …
Run Code Online (Sandbox Code Playgroud)

mysql

2
推荐指数
1
解决办法
77
查看次数

标签 统计

angularjs ×2

javascript ×2

eslint ×1

mysql ×1