angular-routing

embedded Twitter widget on Angular 2+ app only shows up on the first page load

坚强是说给别人听的谎言 提交于 2019-12-01 01:14:33
My app works perfectly if I copy exactly the built-in function from Twitter docs ( https://dev.twitter.com/web/javascript/loading ) into ngAfterViewInit function, but when I switch the route, the widget disappears also. Here is the code to work only for the first page load: import { Component, OnInit, OnDestroy, AfterViewInit } from '@angular/core'; import { Router, NavigationEnd, ActivatedRoute, ParamMap, Params } from '@angular/router'; import { Observable, Subscription } from 'rxjs/Rx'; export class ProjectDetailComponent implements OnInit, OnDestroy, AfterViewInit { constructor( private

angular-rails-templates: templates are not found

巧了我就是萌 提交于 2019-12-01 00:47:24
I have a rails application, using angularjs for the client side development. I try to load a template located in `app/assets/javascripts/templates/': myApp.config(['$routeProvider', function($routeProvider) { $routeProvider. when('/', { templateUrl: '/index.html', controller: 'MainController' }). otherwise({ redirectTo: '/' }); }]); but I always get a error: "Error: [$compile:tpload] Failed to load template: /index.html". I tried to move the "templates" folder out of the javascripts - app/assets/templates and to add it to my assets pipeline load by adding the following line to config

embedded Twitter widget on Angular 2+ app only shows up on the first page load

自作多情 提交于 2019-11-30 21:11:16
问题 My app works perfectly if I copy exactly the built-in function from Twitter docs (https://dev.twitter.com/web/javascript/loading) into ngAfterViewInit function, but when I switch the route, the widget disappears also. Here is the code to work only for the first page load: import { Component, OnInit, OnDestroy, AfterViewInit } from '@angular/core'; import { Router, NavigationEnd, ActivatedRoute, ParamMap, Params } from '@angular/router'; import { Observable, Subscription } from 'rxjs/Rx';

angularjs ui-router stateparams invisible loses on page refresh

删除回忆录丶 提交于 2019-11-30 21:07:59
Im working on a angular project, where i have set my states as shown below. $stateProvider.state('UserPanel', { url: '/user', params: { userId: null }, views: { 'content@': { templateUrl: '/AngViews/UserPanel/UserPanel.UserDetails.html' } } }); when i navigate to the view, it takes the params with it, so this part is working. But when i update the page, it's loses the params. I know that if i defined the params in the url variable it will work. but i want to make it invisible. I have found something like this , but don't know if it's gonna fix my problem. can't get it working if it does.

Property 'url' does not exist on type 'Event' for Angular2 NavigationEnd Event

谁说我不能喝 提交于 2019-11-30 20:23:59
this.subscription = this.router.events.subscribe((event:Event) => { console.log(event.url); ##### Error : Property 'url' does not exist on type 'Event'. } Typescript doesn't recognize the properties of the type Event that is built into the Angular Router. Is there something on tsd that I can use to solve this? Event is the super class of classes NaviagationEnd, NavigationStart You have to import { Event } from @angular/router; . Try moving console into the if block with condition. this.subscription = this.router.events.subscribe((event:Event) => { if(event instanceof NavigationEnd ){ console

angular-rails-templates: templates are not found

一个人想着一个人 提交于 2019-11-30 19:24:51
问题 I have a rails application, using angularjs for the client side development. I try to load a template located in `app/assets/javascripts/templates/': myApp.config(['$routeProvider', function($routeProvider) { $routeProvider. when('/', { templateUrl: '/index.html', controller: 'MainController' }). otherwise({ redirectTo: '/' }); }]); but I always get a error: "Error: [$compile:tpload] Failed to load template: /index.html". I tried to move the "templates" folder out of the javascripts - app

How to get checkbox value in angularjs?

徘徊边缘 提交于 2019-11-30 17:50:41
I have a 10(or n)checkbox in my ng-view. Now I would like to ask here that What is the most efficient or simple way to check if checkbox is checked and if checked get the value of checkbox. <ul> <li ng-repeat="album in albums"> <input type="checkbox" ng-model="folder.Selected" value={{album.name}} /> </li> </ul> I have ng-controller(getAlbumsCtrl) , in that I have an array in which I want to push all the checkedbox albums names into albumNameArray You can loop over the array to find out which is selected and push into the name array. <ul> <li ng-repeat="album in albums"> <input type="checkbox"

angular url is adding unwanted characters

佐手、 提交于 2019-11-30 17:28:09
问题 I had a project where the URL just worked fine when working locally by going to localhost:9000/ the URL would become http://localhost:9000/#/ As of some change I made it now goes to http://localhost:9000/#!/ ( with an exclamation mark ) Also, other URLs become weird. if I try to click on a link that for example, goes to the dashboard. It doesn't take me there. Instead, it makes the URL like /#!/#%2Fdashboard and nothing happens after that. What did I do wrong and how can I possibly solve this

Routing in Angular2 - Link “['Name']” does not resolve to a terminal instruction

放肆的年华 提交于 2019-11-30 11:17:54
I am trying to get a simple app working with child routing. When I setup the routes on my child component I get the following error message: Link "["ChildItem"]" does not resolve to a terminal instruction If I place all the routes on the parent component it works correctly. If I split the routes between the child and parent components I get the above error. Here is it working with all routes on the same component: import {bootstrap} from 'angular2/platform/browser'; import {Component, provide} from 'angular2/core'; import {COMMON_DIRECTIVES, CORE_DIRECTIVES, FORM_DIRECTIVES, NgFor, NgIf} from

How to implement multi-level routing in Angular?

↘锁芯ラ 提交于 2019-11-30 10:03:02
I'm working on a little project of mine in order to learn something more about Angular, but I really cannot figure out how to implement a multi-leveled routing. I've read the documentation about the new release of the Router Component and also some other topics on StackOverlfow ( first , second , third ), but I cannot find a solution to my problem. Let's consider the following app structure , without considering the Test and Test2 blocks. And let's consider the components of my app as following: main.ts import { bootstrap } from '@angular/platform-browser-dynamic'; import { MyAppComponent }