0

I'm learning Angular 2 so still not familiar with how it implements plugins. I'm trying to implement angular bootstrap toggle: http://ziscloud.github.io/angular-bootstrap-toggle/

Instructions say: As soon as you've got all the files downloaded and included in your page you just need to declare a dependency on the ui.toggle module: angular.module('myModule', ['ui.toggle']);

I'm not sure what that means. I just got used to declaring them in package.json and app.module.ts.

I don't see anywhere in these files where I might add that line.

package.json looks like this:

{
  "name": "arv2",
  "dependencies": {
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
...
    "mydatepicker": "^2.0.21",
    "ng2-validation": "^4.2.0",
  },
  "devDependencies": {
    "@angular/cli": "1.0.2",
    "@angular/compiler-cli": "^4.0.0",
...
    "webpack-dev-server": "~2.4.2",
    "webpack-hot-middleware": "^2.18.0"
  }
}

and app.module.ts looks like this:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, APP_INITIALIZER  } from '@angular/core';
...
import { CustomFormsModule } from 'ng2-validation';

@NgModule({
    declarations: [
        AppComponent,
        SwitchClientComponent,
        SwitchClientPipe,
        ...
    ],
    imports: [
        BrowserModule,
    ...
    ],
    providers: [
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }

finally, the actual page I'm trying to implement it on looks like this:

import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';

@Component({
  selector: 'app-switch-client',
  templateUrl: './switch-client.component.html',
  styleUrls: ['./switch-client.component.scss']

})
export class SwitchClientComponent implements OnInit {
  ...
}

1 Answer 1

1

this angular bootstrap toggle is a concept for AngularJS and not for Angular2. So you should search for a Plugin, that run on Angular 2.

If you need no text inside, you can look here https://material.angular.io/components/slide-toggle/overview

And if you want to use the bootstrap switcher, maybe this is one for you jw-bootstrap-switch-ng2

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.