I try to customize my datepicker by following this :
https://productblog.townscript.com/customizing-angular-ui-bootstrap-directives-c4461c12afa9#.hfvv6e2il
On theses lines of code :
$provide.decorator('daypickerDirective', function ($delegate) {
var directive = $delegate[0];
directive.templateUrl = "custom-template/datepicker/day.html";
return $delegate;
});
I've this error :
Unknown provider: daypickerDirectiveProvider
Note : I'm a newbie :/
Any idea ?
Update 1
http://plnkr.co/edit/1IJtST5eGrWVipLip7hX
Yes, I've found the solution :
https://github.com/spongessuck/gm.datepickerMultiSelect/issues/28
The v1.0.6 doesn't support it, because you are decorating
daypickerDirective and not the new uibDaypickerDirective.
Related
I am building an angular plugin named breadcrumb here, it works fine until I update ui-router version to '1.0.0-beta.2'. the cause is that I can't get resolved data from $state.$current.
in html
specify display name property to data.displayName in html
<breadcrumbs display-name-property="data.displayName"></breadcrumbs>
state config
displayName is dynamic
.state('app.dict.list.tree', {
...
data: {
displayName: '{{title}}'
},
resolve: {
title: ['$transition$', $transition$ => $transition$.params().title],
}
})
directive link function
i use $interpolate service to compile propertyReference(in this case '{{title}}') with the context $state.$current.locals.global.
var currentState = $state.$current;
interpolationContext = (typeof currentState.locals !== 'undefined') ? currentState.locals.globals : currentState;
displayName = $interpolate(propertyReference)(interpolationContext);
update ui-router to the latest version, this code won't work anymore, currentState.locals is undefined, and I can't find a way to access resolved data in currentState object.
does anybody know how to do it? any help will be appreciated.
I found $state.getCurrentPath() gives a list of pathNodes which includes resolved data.
It is similar to Transition's treeChanges().to which is available only when transition occurs
if(legacyRouter){
scope.$on('$stateChangeSuccess', function() {
updateBreadcrumbsArray();
});
}else{
$injector.get('$transitions').onSuccess({}, function(trans){
resolved(trans, updateBreadcrumbsArray)
})
}
/**
* get all resolved data in state declare and use them to compile display name
* */
function resolved(trans, fn){
var tokens = trans.getResolveTokens();
var resolves = {};
var promises = tokens.map(function(token){
var resolved = trans.injector().get(token);
resolves[token] = resolved;
return resolved;
});
$q.all(promises).then(function(){
fn(resolves);
})
}
I have a Cordova plugin that do some webservice thinks, and i want it to make a call a angular factory function on the WebView using the sendJavascript android command.
I have another project where it works without angularjs.
AngularJS factory
....
.factory('playerService', function(){
var title = "Tryk på play";
var setTitle = function(t) {
title = t;
}
var getTitle = function() {
return title;
}
return {
setTitle : setTitle,
getTitle : getTitle
}
})
....
Cordova plugin
....
cordova.webView.sendJavascript("javascript: playerService.setTitle('test test');
....
I got a "playerService" is not defined - in the logcat android output.
Finally i got a solution ...
1) First i got to select a element in the DOM witch is in the scope. In my example i have an div with the ID playbuttons
cordova.webView.sendJavascript("javascript: angular.element(document.querySelector('#playbuttons')).scope().$apply(function() {angular.element(document.querySelector('#playbuttons')).scope().playerService.setTitle('TESTING')})");
I think this i very hacky, so if anyone can correct me, the feel free ;)
I'm trying to use Ext.util.DelayedTask to make some timed functions go off. I'm getting the error Uncaught TypeError: undefined is not a function call. It's coming from line 126 of DelayedTask.js in the Sencha source code. Click here to see the source.
Here is the code I wrote which runs the tasks.
var appView = Ext.ComponentQuery.query('.meterreadings_main')[0];
var meterList = Ext.ComponentQuery.query('.mbList[alias="meterListObject"]')[0];
var taskOne = Ext.create('Ext.util.DelayedTask', {
scope: this,
fn:function() {
appView.pop();
}
});
var taskTwo = Ext.create('Ext.util.DelayedTask', {
scope: this,
fn:function() {
meterList.select(meterStore.getCurrentRecordIndex());
}
});
var taskThree = Ext.create('Ext.util.DelayedTask', {
scope: this,
fn:function() {
meterList.config.itemTapHandler(null,meterStore.getCurrentRecordIndex(), null,
meterStore.getCurrentRecord(), null, null);
}
});
appView.pop();
taskOne.delay(500);
taskTwo.delay(1500);
taskThree.delay(2500);
See anything wrong?
Even though the ST2 docs show that you can create a delayed task like how you are currently doing, you actually need to do it the following way:
var taskOne = Ext.create('Ext.util.DelayedTask', function() {
console.log('delayed task');
}, this);
Here are the parameters you can pass, you'll see I already included the scope above:
Parameters
fn : Function
The default function to call.
scope : Object
The default scope (The this reference) in which the function is called. If not specified, this will refer to the browser window.
args : Array
The default Array of arguments.
Good Luck!
I'm trying this easy code from Addy's book but I can't make it work:
var TodoRouter = Backbone.Router.extend({
routes: {
"about" : "showAbout",
"search/:query" : "searchTodos",
"search/:query/p:page" : "searchTodos"
},
showAbout: function(){},
searchTodos: function(query, page){
var page_number = page || 1;
console.log("Page number: " + page_number + " of the results for todos containing the wo");
}
});
var myTodoRouter = new TodoRouter();
Backbone.history.start();
The console returns this with an error:
Uncaught TypeError: Property '$' of object #<Object> is not a function backbone-min.js:1
h.extend.start backbone-min.js:1
(anonymous function)
If I comment out Backbone.history.start() there's no error (neither the "app" behaves the way it is supposed to behave).
Any help is appreciated.
[SOLVED] the JS files (JQuery, Underscore and Backbone were added to HTML in the wrong order. The right order for me was: JQuery, Underscore, Backbone, MyOwnJSFiles. Thanks anyone for reading, hope this helps
Here is my error:
Uncaught NoTemplateError: Could not find template: '<!-- HTML Template -->
<div id="start_div">
<h2>Choose your path to ... // the rest of the template
It is telling me that there is no template but then it outputs the template that it said it could not find.
Here is my code:
require(["jquery", "marionette", "views/StartView" ],
function($, marionette, StartView) {
var SCApp = new marionette.Application();
SCApp.addRegions({
mainRegion: "#center_court"
});
var startView = new StartView();
SCApp.mainRegion.show(startView);
SCApp.start();
}
Here is the StartView.js
define(["jquery", "marionette", "text!templates/startDiv.html"],
function($, marionette, template){
var StartView = marionette.ItemView.extend({
//template: "#start_div"
template: template
});
// Returns the View class
return StartView;
});
Can anyone see what I'm doing wrong? Do I need something for templating in the require method?
Any suggestion are greatly appreciated.
Andrew
Usually Marionette search for a template inside the DOM with an ID equal to the one you reference in your view, so you have to change the loadTemplate from Marionette.TemplateCache in this way:
Backbone.Marionette.TemplateCache.prototype.loadTemplate = function(templateId) {
var template = templateId;
if (!template || template.length === 0){
var msg = "Could not find template: '" + templateId + "'";
var err = new Error(msg);
err.name = "NoTemplateError";
throw err;
}
return template;
};
I actually don't remember where I found this function, I can't find it anymore in Marionette's Wiki, anyway it's working fine for me.
I had the same issue yesterday and found the next interesting facts:
When I've changed the 'not found' template's content, it wasn't changed in error message.
When I've changed it's file name (and updated it in import statement) — the error was fixed, updated content was shown.
... then I've changed the name back, everything was fine.
Looks like some bug with caching.
Upd: here I found deep analysis and solution:
http://blog.icanmakethiswork.io/2014/03/caching-and-cache-busting-with-requirejs.html