Angular multiple - replacing / with test data

by Harsha Jayamanna

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.js"></script>
<script src=" https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
<div ng-app="sample">
  <div ng-controller="materialController">
  <h1>
  Method 1 (math):
  </h1>
  <ol>
  <li>Ampersand (&) is interpreted as text “and”.</li>
  <li>Plus (+) is interpreted as text “plus”.</li>
  <li>Sharp (#) is ignored.</li>
  <li>Alpha/numeric/special character sequence followed by a space list before a matching sequence followed by additional alpha/numeric/special characters. E.G. West goes before Western".</li>
  <li>No special treatment for Foreign Characters.</li>
  <li>Special characters are not given the least priority.</li>
  </ol>
  <h2>
  Original Result
  </h2>
    <ul>
      <li ng-repeat="material in materials">
        {{ material.name}} , {{ material.edition}}
      </li>
    </ul>
  <h2>
  Sorted Result
  </h2>
    <ul>
      <li ng-repeat="material in materials | orderBy : ['srtName','-edition']">
        {{ material.name}} , {{ material.edition}} 
      </li>
    </ul>
  </div>
</div>

CSS

body {
  font-family: Arial;
}

JavaScript

var app = angular.module('sample', []);
app.controller('materialController', function($scope) {
  $scope.materials = [];
	
  function removeSpecificCharacters(text) {
        var txt = text.replace(/[&]/gi, ' and ');
        txt = $.trim(txt.replace(/[+]/gi, ' plus '));
        txt = $.trim(txt.replace(/[#]/gi, ' sharp '));
        txt = $.trim(txt.replace(/\s+/g, ' '));
        return txt;
  };
    
  function getMaterials() {
    $scope.materials = 
    [{
    	name: '0134310993',
      edition:'2e'
    },
    {
    	name: 'Algebra & Trigonometry, Second Custom Edition for Tidewater Community College',
      edition:'2e'
    },
    {
    	name: 'Algebra and Statistics, Second Custom Edition for Jackson Community College; MATH 033',
      edition:'2e'
    },
    {
    	name: 'Algebra and Trigonometry with Modeling and Visualization, Fourth Custom Edition for Oregon State University',
      edition:'1e'
    },
    {
    	name: 'Algebra for College Students, A Custom Edition for the University of Nevada Reno',
      edition:'1e'
    },
    {
    	name: 'Algebra, Functions, and Modeling, Custom Edition for Jefferson Community College',
      edition:'2e'
    },
    {
    	name: 'Applied Statistics, Custom Edition for Middle Tennessee State University MATH 1530K',
      edition:'1e'
    },
    {
    	name: 'Basic College Mathematics, Custom Edition for Morton College',
      edition:'3e'
    },
    {
    	name: 'Basic Math, Introductory and Intermediate Algebra',
      edition:'2e'
    },
    {
    	name: 'Basic Math, Introductory and Intermediate Algebra, 1/e Ready To Go MyMathLab Course',
      edition:'1e'
    },
    {
    	name: 'Basic, Beginning and Intermediate Algebra, Custom Edition for St. Louis Community Colleg',
      edition:'1e'
    },
    {
    	name: 'Beginning & Intermediate Algebra, Custom Edition for Colorado Mesa University',
      edition:'1e'
    },
    {
    	name: 'College Algebra in Context with Applications for the Managerial, Life, and...