Thursday, 15 July 2010

AngularJS - updating service-based model from directive -



AngularJS - updating service-based model from directive -

i think i've flaw in design of angularjs app.

i have service contains 1 of model items , methods associated adding/deleting them. service injected core app , directive. issue removing items in model directive. doing because directive physically represents each of model items. alter happening, not pushing way core app exposes model. realize because i'm not telling update, issue don't understand how to. adding $apply in directive after calling service causes error apply in progress, feels wrong approach.

i've set model in service want single instance of info entire app.

can suggest improve way of achieving this? storing model in service idea?

service:

angular.module("app").service("widgetservice", function () { this.widgets = []; this.removewidget = function() { <!-- remove item this.widgets --> } this.getwidgets = function() { homecoming this.widgets; } this.setwidgets = function(widgets) { this.widgets = widgets; ) }

core app:

app.controller("coreappcontroller", function($scope, $http, widgetservice) { $scope.widgets = widgetservice.getwidgets(); }

html:

<widget data-ng-repeat="widget in widgets" />

directive:

mykss.mykssapp.directive("widget", function($compile) { homecoming { restrict: "e", replace: true, templateurl: "partials/widget.html", scope: { }, controller: function($scope, $element, $attrs, widgetservice) { $scope.removewidget = function() { widgetservice.removewidget(); }; } } }

there 1 thing i've notices: shouldn't give possibility alter value of widgets variable of service - otherwise couldn't track adding/removing (i mean this.setwidgets method of service should removed)

everything else should work (with other minor changes): http://plnkr.co/edit/fqmwfi5d7nikjhxtxsc6?p=preview

angularjs

php - sqlsrv_connect: Login failed for user -



php - sqlsrv_connect: Login failed for user -

i testing out new installation of 5.3:

<?php $servername = "ks252"; $connectioninfo = array( "database"=>"ocustom"); /* connect using windows authentication. */ $conn = sqlsrv_connect( $servername, $connectioninfo); if( $conn === false ) { echo "unable connect.</br>"; die( print_r( sqlsrv_errors(), true)); } ?>

and getting error:

unable connect. array ( [0] => array ( [0] => 28000 [sqlstate] => 28000 [1] => 18456 [code] => 18456 [2] => [microsoft][sql server native client 11.0][sql server]login failed user 'nt authority\anonymous logon'. [message] => [microsoft][sql server native client 11.0][sql server]login failed user 'nt authority\anonymous logon'. ) [1] => array ( [0] => 28000 [sqlstate] => 28000 [1] => 18456 [code] => 18456 [2] => [microsoft][sql server native client 11.0][sql server]login failed user 'nt authority\anonymous logon'. [message] => [microsoft][sql server native client 11.0][sql server]login failed user 'nt authority\anonymous logon'. ) )

what mean>? doing wrong?

php sql-server iis sql-server-2012

xbmc - Python if valuea is equal and if valueb is not equal -



xbmc - Python if valuea is equal and if valueb is not equal -

i made little script work xbmc , i'm not able work. here code:

import xbmcgui import xbmc while (not xbmc.abortrequested): win = (xbmcgui.getcurrentwindowid()) menu = 0 if win == 10000 , menu != 10000: print ("home menu") menu = 10000

all want when home menu there, write log (but once) write in log when on menu

thanks in advance

set menu = 0 outside of while loop; resetting 0 each time otherwise:

menu = 0 while (not xbmc.abortrequested): win = (xbmcgui.getcurrentwindowid()) if win == 10000 , menu != 10000: print ("home menu") menu = 10000

python xbmc

javascript - Backbone dynamically set collection view el after click on dom element -



javascript - Backbone dynamically set collection view el after click on dom element -

the project calendar model 1 day , collection contain days month. view same. when render collection have calendar on screen. need, able set todo list in selected day. need model,view , collection. thought tasks 1 day day collection - , there go problem : how set new collection view "el" element of clicked day , id. each day has got same class , unique id equal date - "2013.02.08" not sure possible or maybe approach wrong , should in way. edit - ok lets clarify :

i know there in no collection of collections how ? have calendar on screen - imagine 31 square divs. want todo list in each of them - :

model of task view of task {li element} view of tasks {ul element} collection of tasks {model:model}

in each of squares. how store collections ?

javascript backbone.js backbone-views

webgl - Three.js globe rotate on click -



webgl - Three.js globe rotate on click -

i have created rotating globe has hostspots fire modal when clicked on. globe spin , have hotspot clicked on @ centre of screen. code below rotates globe doesn't centre desired. kindly provide pointers

checkhotspotclick: function(){ var me = this; window.cancelanimationframe(me.animate) //get normalized mousecoords -1 -> 1 var mouse2dx = (mousex/me.windowdimensionx)*2-1 var mouse2dy = -(mousey/me.windowdimensiony)*2+1 //for utilize orthographic photographic camera var vecorigin = new three.vector3( mouse2dx, mouse2dy, - 1 ); var vectarget = new three.vector3( mouse2dx, mouse2dy, 1 ); me.projector.unprojectvector( vecorigin, me.camera ); me.projector.unprojectvector( vectarget, me.camera ); vectarget.subself( vecorigin ).normalize(); var ray = new three.ray(); ray.origin = vecorigin; ray.direction = vectarget; var intersects = ray.intersectobjects(me.hotspotsarr); if (intersects.length > 0) { console.log($(me.hotspotdivsarr[intersects[0].object.name]).html()) // ajax overide me.targetrotation_x += (me.options.camx-mouse2dx)*12; me.targetrotation_y += (me.options.camy+mouse2dy)*12; me.dozoom(-6); console.log(me.targetrotation_x); var country_id = $(me.hotspotdivsarr[intersects[0].object.name]).data('id'); url = 'home/getprojectdata'; $("#mymodal").load(url,{ s: country_id }); settimeout(function() {$("#mymodal").modal('show')},2000); $('#mycarousel').carousel($(this).data('slide-index')); /*me.targetrotation_x = 0;*/ } else { me.dozoom(+6); } },

three.js webgl

scripting - Search String using Shell Awk -



scripting - Search String using Shell Awk -

i have string:

the disk 'virtual memory' known 'virtual memory' has exceeded maximum utilization threshold of 95 percent.

i need search every time in string word the disk , if found need extract phrase in '*' known '*' , set in variable monitor

in other words want search , set value to

monitor="'virtual memory' known virtual memory'"

how can using awk?

here's snippet describe. should set in $(...) assign $monitor variable:

$ awk '/the disk '\''.*'\'' known '\''.*'\'' has exceeded/ {gsub(/the disk /,"");gsub(/ has exceeded.*$/,"");print}' input.txt

the 2 problems awk in case is

it doesn't have submatch extraction on regexes (which why solution uses gsub() in body rid of first , lastly part of line. to utilize quotes in awk regex in shell script need '\'' sequence scape (more info here)

shell scripting awk

html - Fixed width columns with fluid gutters -



html - Fixed width columns with fluid gutters -

i know can done columns, have back upwards ie.

i'm trying layout columns fixed width, gutters beingness fluid.

i couldn't work floats, settled on using justified inline-block items:

html

<div class="wrapper"> <div></div> <div></div> <div></div> <!-- more divs... --> </div>

css

class="lang-css prettyprint-override">.wrapper { text-align: justify; } .wrapper div { width: 100px; display: inline-block; }

this works wonderfully, lastly row of divs aligned left: http://jsfiddle.net/eshh3/

the solution found add together additional unnecessary divs: http://jsfiddle.net/eshh3/1/

i sense uncomfortable this, i'd know if there other options.

please don't tell me not re-invent wheel. have not found fluid grid scheme supports fluid gutters.

for want do, i'm afraid css solution not available @ moment, much less if want work in ie8.

since want have (a) items in html source list (b) variable number of columns depending on available space (c) column spacing depending on width of container think solution you'll need have employ @ to the lowest degree bit of javascript.

consider on of frameworks proposed in other answers. 1 i've worked , want masonry (or for-pay bigger brother isotope). (there's non-jquery version of masonry). you'll have come function when page resized, recalculates desired gutter , reconfigures framework. along lines of calculating x = how many items fit per line based on container width , item width , dividing remaining space x-1.

if want stick thought of adding div's markup, alternative hear resize events, , add together divs needed based on width , how many items fit per line.

original answer, failed fit criteria.

since you're relying on text-align: justified reason lastly line doesn't expand total width because there's no line break @ end of it. accomplish add together element wrapper:after {} rule, inline block width of 100% guaranties line break.

see fiddle

the css ends like:

.wrapper { text-align: justify; width: 380px; margin: 0 auto; } .wrapper div { width: 100px; display: inline-block; } .wrapper:after {content: ''; width: 100%; display: inline-block; background: pink; height: 2px; overflow: hidden}

note pinkish background there can see element is. might need play border/margin/padding of element or wrapper content comes after wrapper doesn't gain margin. in chrome unfortunately there's slight missalignment of lastly row items, perchance because of space between lastly div , false element.

html css html5 grid fluid-layout