我试图表现出div使用动画ng-hide和ng-show,它不能正常工作.当我提到一个特定的高度它正常工作,如果我提到最小高度它不工作.
.sample-show-hide {
opacity: 1;
min-height: 180px;
}
.sample-show-hide.ng-hide-add,
.sample-show-hide.ng-hide-remove {
transition: all linear 0.5s;
}
.sample-show-hide.ng-hide {
min-height: 0px;
opacity: 0;
}
Run Code Online (Sandbox Code Playgroud)
<div class="row" ng-click="showDiv=true">
<h2>Click me</h2>
</div>
<div class="row sample-show-hide" ng-show="showDiv=!showDiv">
<h2>some data</h2>
<h2>some data</h2>
<h2>some data</h2>
<h2>some data</h2>
</div>
Run Code Online (Sandbox Code Playgroud)
如果我提到一个特定的高度,如下所示它正常工作,那么如果我向该div添加一些额外的数据,那么它的高度为80px,只有剩余的数据没有显示因为特定的高度,所以如果我添加额外的文本也表示div必须自动取高度
.sample-show-hide {
opacity: 1;
height: 80px;
}
.sample-show-hide.ng-hide-add,
.sample-show-hide.ng-hide-remove {
transition: all linear 0.5s;
}
.sample-show-hide.ng-hide {
height: 0px;
opacity: 0;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试将网络通知放到我的网站上,这样当我在我的网站中添加任何新项目时,我的所有客户都会在浏览器中看到我的通知.
我选择了angular-web-notification,我在我的应用程序中通过Bower安装并在本地测试,它工作正常但是当我将我的网站部署到生产中时,我再次在生产中测试,通知仅在我的浏览器中出现允许我网站通知的所有客户.
这是我的代码:
.directive('showButton', ['webNotification', function (webNotification) {
return {
restrict: 'C',
scope: {
notificationTitle: '=',
notificationMsg: '=',
notificationUrl: '='
},
link: function (scope, element) {
console.log("coming to directive notifications")
element.on('click', function onClick() {
console.log("coming to directive notifications click")
if ((scope.notificationTitle) && (scope.notificationMsg)) {
webNotification.showNotification(scope.notificationTitle, {
body: scope.notificationMsg,
icon: 'https://lh3.googleusercontent.com/BCOE0vqCfr8aqpIKEF7QEt-qa7p8I7KDg58Juz6M6_YGb4l7phrO2vMvi_SDy10ucQ=w300',
onClick: function onNotificationClicked() {
console.log('Notification clicked.');
window.open(scope.notificationUrl, '_blank')
},
autoClose: 4000 //auto close the notification after 4 seconds (you can manually close it via hide function)
}, function …Run Code Online (Sandbox Code Playgroud) javascript push-notification web-notifications angularjs angularjs-directive
我正在尝试使用ng-show和ng-hide使用指令来改善多个条件,这是我的代码
HTML代码
<my-directive controls="a,b,c"></my-directive>
Run Code Online (Sandbox Code Playgroud)
js代码
.directive('myDirective',function(){
return{
restrict:'E',
templateUrl:"parentHtml.html",
link:function(scope,elem,attr){
var options = attr.controls;
if(options=="a,b,c"){
scope.showMeAll=true;
}else if(options=="a"){
scope.showmeA=true;
}else if(options=="b"){
scope.showmeB=true;
}else if(options=="c"){
scope.showmeC=true;
}
}
}
}).directive('subDirective',function(){
return{
restrict:'E',
template:"<h2>aapple</h2>",
link:function(scope,elem,attr){
}
}
}).directive('subDirective1',function(){
return{
restrict:'E',
template:"<h2>BBatt</h2>",
link:function(scope,elem,attr){
}
}
}).directive('subDirective2',function(){
return{
restrict:'E',
template:"<h2>CCat</h2>",
link:function(scope,elem,attr){
}
}
});
Run Code Online (Sandbox Code Playgroud)
这是我的parentHtml.html代码
<div class="row">
<div ng-show="showMeAll">
<sub-directive></sub-directive>
</div>
<div ng-show="showMeB">
<sub-directive1></sub-directive1>
</div>
<div ng-show="showMeC">
<sub-directive2></sub-directive2>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我的问题是当我将所有三个"a,b,c"赋予指令属性然后在"parentHtml"中所有三个div必须显示,如果我只给出两个即"a,b"那么在parentHtml中只有两个div的必须显示即"苹果"和"蝙蝠",如果只给出一个字符串,即"c",那么在parentHtml中只有"cat"div必须以简单的方式显示我给指令属性thet div的字母表是什么必须表明.这是我的http://plnkr.co/edit/6gAyAi63Ni4Z7l0DP5qm?p=preview.请以简单的方式解决我的问题.
提前致谢
我试图在我使用时将数据发送到控制器的指令链接功能ng-clicked,但是我没有将数据发送到指令,该指令在第一次加载页面时调用
<h2 ng-click="clickMe(somedata)"> click </h2>
<my-directive my-key="myVal"> </my-directive>
Run Code Online (Sandbox Code Playgroud)
.controller('myController',function($scope){
$scope.clickMe=function(somedata){
$scope.myVal=somedata;
};
});
Run Code Online (Sandbox Code Playgroud)
.directive('myDirective',function(){
return{
restrict:'E',
scope:{
myKey:'='
},
templateUrl:'exampleTempl.html',
controller:'myController',
link:function(scope,elem,attr){
console.log(scope.myKey); // getting undefined
console.log(scope.myVal); //here i want the data from controller when i clicked on ng-click
}
}
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试将 a 返回Promise.all()到一个函数。我尝试了不同的方法,但它显示错误
// All this iam doing in my server side controller
Promise = require('bluebird');
function countByTitle(accrdnArray) {
console.log(accrdnArray) // array of objects is printing here
var arrayCount = countfunc(accrdnArray);
console.log(JSON.stringify(arrayCount)) // here it is not printing showing error
}
function countfunc(accrdnArray) {
var array = [];
for (var i = 0; i < accrdnArray.lenght; i++) {
var heading = accrdnArray[i].name;
array.push(mongoCount(heading));
}
return Promise.all(array).then(resultantCount => {
console.log(JSON.stringify(resultantCount)); // resultanCout printing here
return resultantCount
})
// …Run Code Online (Sandbox Code Playgroud) 而IAM试图建立我的应用程序的一些gradle这个更新用被动态地完成,那我的构建是失败后,我搜索我的问题,但没有一个奥雅纳我的错误,在那之后我试图创建一个新的应用程序,并试图执行的应用程序一样的我以前,在实现新的时,我需要安装离子本机插件fileOpener和geolocation,所以在安装这些插件后,我的构建失败,出现以下错误.
:app:processDebugResources
C:\Users\midhun\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\056084560d1bc05d95277a5df08184ea\res\values\values.xml:246:5-69: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\midhun\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\056084560d1bc05d95277a5df08184ea\res\values\values.xml:246:5-69: AAPT: error: resource android:attr/ttcIndex not found.
D:\Tineri-v3\platforms\android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:223: error: resource android:attr/fontVariationSettings not found.
D:\Tineri-v3\platforms\android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:223: error: resource android:attr/ttcIndex not found.
error: failed linking references.
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:551)
at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:285)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107) …Run Code Online (Sandbox Code Playgroud)